com php-src: Fix #77638: var_export'ing certain class instances segfaults: NEWS ext/standard/tests/general _functions/bug77638_1.phpt
ext/standard/var .c

From: Date: Mon, 25 Nov 2019 14:54:11 +0000
Subject: com php-src: Fix #77638: var_export'ing certain class instances segfaults: NEWS ext/standard/tests/general _functions/bug77638_1.phpt
ext/standard/var .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-109318@lists.php.net to get a copy of this message
Commit: 23c65a817390d219bbe77f363cf14956c5c7119b Author: Christoph M. Becker <cmbecker69@gmx.de> Mon, 25 Nov 2019 15:44:15 +0100 Parents: bb30fe9e2b86a46a167c88daaae0c650cb01afa2 Branches: PHP-7.3 PHP-7..4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=23c65a817390d219bbe77f363cf14956c5c7119b Log: Fix #77638: var_export'ing certain class instances segfaults If objects return immutable property hash tables (typically, zend_empty_array), we must not try to apply recursion protection on those. Bugs: https://bugs.php.net/77638 Changed paths: M NEWS A ext/standard/tests/general_functions/bug77638_1.phpt M ext/standard/var.c Diff: diff --git a/NEWS b/NEWS index 2961969c612..4f025197115 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,7 @@ PHP NEWS - Standard: . Fixed bug #78759 (array_search in $GLOBALS). (Nikita) + . Fixed bug #77638 (var_export'ing certain class instances segfaults). (cmb) 21 Nov 2019, PHP 7.3.12 diff --git a/ext/standard/tests/general_functions/bug77638_1.phpt b/ext/standard/tests/general_functions/bug77638_1.phpt new file mode 100644 index 00000000000..b5ad2b6acf6 --- /dev/null +++ b/ext/standard/tests/general_functions/bug77638_1.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #77638 (var_export'ing certain class instances segfaults) +--SKIPIF-- +<?php +if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available'); +?> +--FILE-- +<?php +var_export(new COM("Scripting.Dictionary")); +?> +--EXPECT-- +com::__set_state(array( +)) diff --git a/ext/standard/var.c b/ext/standard/var.c index 2562a410f05..a008aab4cbf 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -524,7 +524,7 @@ again: zend_error(E_WARNING, "var_export does not handle circular references"); return; } else { - GC_PROTECT_RECURSION(myht); + GC_TRY_PROTECT_RECURSION(myht); } } if (level > 1) { @@ -544,7 +544,7 @@ again: ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) { php_object_element_export(val, index, key, level, buf); } ZEND_HASH_FOREACH_END(); - GC_UNPROTECT_RECURSION(myht); + GC_TRY_UNPROTECT_RECURSION(myht); } if (level > 1) { buffer_append_spaces(buf, level - 1);

« previous php.cvs (#109318) next »