From: Felipe Pena Date: Fri, 2 Apr 2010 21:44:09 +0000 (+0000) Subject: - Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection) X-Git-Tag: php-5.3.3RC1~341 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a140e70661b698d0f2527dadbc956bd2e98bc9b9;p=php - Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection) --- diff --git a/NEWS b/NEWS index 2b0f47950c..075200bb34 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP NEWS - Fixed a NULL pointer dereference when processing invalid XML-RPC requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert) +- Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection). (Felipe) - Fixed bug #51394 (Error line reported incorrectly if error handler throws an exception). (Stas) - Fixed bug #51393 (DateTime::createFromFormat() fails if format string contains diff --git a/Zend/tests/bug35163.phpt b/Zend/tests/bug35163.phpt index 4501fa9372..6a10d244ba 100755 --- a/Zend/tests/bug35163.phpt +++ b/Zend/tests/bug35163.phpt @@ -17,22 +17,8 @@ array(1) { [0]=> int(2) [1]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* [2]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* } } diff --git a/Zend/tests/bug35163_2.phpt b/Zend/tests/bug35163_2.phpt index 4adf7709ae..01387204c8 100755 --- a/Zend/tests/bug35163_2.phpt +++ b/Zend/tests/bug35163_2.phpt @@ -20,46 +20,17 @@ array(3) { [0]=> int(2) [1]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* [2]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* } [2]=> &array(3) { [0]=> int(2) [1]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* [2]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* } } - diff --git a/Zend/tests/bug35163_3.phpt b/Zend/tests/bug35163_3.phpt index d2b3c25bfe..6c6a57f254 100755 --- a/Zend/tests/bug35163_3.phpt +++ b/Zend/tests/bug35163_3.phpt @@ -11,29 +11,15 @@ var_dump($a); $a->b = null; $a = null; ?> ---EXPECT-- -object(stdClass)#1 (1) { +--EXPECTF-- +object(stdClass)#%d (1) { ["b"]=> &array(3) { [0]=> int(2) [1]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* [2]=> - &array(3) { - [0]=> - int(2) - [1]=> - *RECURSION* - [2]=> - *RECURSION* - } + *RECURSION* } } diff --git a/Zend/tests/bug35239.phpt b/Zend/tests/bug35239.phpt index 7fc7b7d3b6..869971e2a2 100755 --- a/Zend/tests/bug35239.phpt +++ b/Zend/tests/bug35239.phpt @@ -12,30 +12,16 @@ var_dump($a); $a->x0->y1 = "ok\n"; echo $a->x0; ?> ---EXPECT-- -object(stdClass)#1 (1) { +--EXPECTF-- +object(stdClass)#%d (1) { ["x0"]=> - &object(stdClass)#2 (3) { + &object(stdClass)#%d (3) { ["y0"]=> string(1) "b" ["y1"]=> - &object(stdClass)#2 (3) { - ["y0"]=> - string(1) "b" - ["y1"]=> - *RECURSION* - ["y2"]=> - *RECURSION* - } + *RECURSION* ["y2"]=> - &object(stdClass)#2 (3) { - ["y0"]=> - string(1) "b" - ["y1"]=> - *RECURSION* - ["y2"]=> - *RECURSION* - } + *RECURSION* } } ok diff --git a/Zend/tests/closure_020.phpt b/Zend/tests/closure_020.phpt index 7b4c60b9bd..9d04a9af54 100644 --- a/Zend/tests/closure_020.phpt +++ b/Zend/tests/closure_020.phpt @@ -31,18 +31,7 @@ object(foo)#%d (%d) { ["static"]=> array(1) { ["a"]=> - &object(foo)#%d (2) { - ["test":"foo":private]=> - int(3) - ["a"]=> - object(Closure)#%d (1) { - ["static"]=> - array(1) { - ["a"]=> - *RECURSION* - } - } - } + *RECURSION* } } } diff --git a/Zend/tests/closure_034.phpt b/Zend/tests/closure_034.phpt index d1356c31da..8ba276a68a 100644 --- a/Zend/tests/closure_034.phpt +++ b/Zend/tests/closure_034.phpt @@ -9,17 +9,11 @@ var_dump($a); ?> ===DONE=== --EXPECTF-- -object(Closure)#1 (1) { +object(Closure)#%d (1) { ["static"]=> array(1) { ["a"]=> - &object(Closure)#1 (1) { - ["static"]=> - array(1) { - ["a"]=> - *RECURSION* - } - } + *RECURSION* } } ===DONE=== diff --git a/Zend/tests/closure_035.phpt b/Zend/tests/closure_035.phpt index ac8b4caea0..e39a991ab6 100644 --- a/Zend/tests/closure_035.phpt +++ b/Zend/tests/closure_035.phpt @@ -18,14 +18,8 @@ var_dump($x()); object(Closure)#%d (1) { ["static"]=> array(1) { - [%u|b%"x"]=> - &object(Closure)#%d (1) { - ["static"]=> - array(1) { - [%u|b%"x"]=> - *RECURSION* - } - } + ["x"]=> + *RECURSION* } } int(1) diff --git a/Zend/tests/foreach_002.phpt b/Zend/tests/foreach_002.phpt index 643e653927..5523424ce9 100644 --- a/Zend/tests/foreach_002.phpt +++ b/Zend/tests/foreach_002.phpt @@ -15,9 +15,6 @@ array(1) { ["a"]=> &array(1) { ["a"]=> - &array(1) { - ["a"]=> - *RECURSION* - } + *RECURSION* } } diff --git a/Zend/tests/gc_004.phpt b/Zend/tests/gc_004.phpt index 8ff5bebfb2..1b6f70abe6 100644 --- a/Zend/tests/gc_004.phpt +++ b/Zend/tests/gc_004.phpt @@ -16,10 +16,7 @@ array(1) { [0]=> &array(1) { [0]=> - &array(1) { - [0]=> - *RECURSION* - } + *RECURSION* } } int(1) diff --git a/Zend/tests/gc_005.phpt b/Zend/tests/gc_005.phpt index 97b368fce6..71fb8909f5 100644 --- a/Zend/tests/gc_005.phpt +++ b/Zend/tests/gc_005.phpt @@ -11,13 +11,10 @@ unset($a); var_dump(gc_collect_cycles()); echo "ok\n" ?> ---EXPECT-- -object(stdClass)#1 (1) { +--EXPECTF-- +object(stdClass)#%d (1) { ["a"]=> - object(stdClass)#1 (1) { - ["a"]=> - *RECURSION* - } + *RECURSION* } int(1) ok diff --git a/Zend/tests/gc_006.phpt b/Zend/tests/gc_006.phpt index 0b3a91e2f4..c633d038f0 100644 --- a/Zend/tests/gc_006.phpt +++ b/Zend/tests/gc_006.phpt @@ -12,18 +12,12 @@ unset($a); var_dump(gc_collect_cycles()); echo "ok\n" ?> ---EXPECT-- -object(stdClass)#1 (1) { +--EXPECTF-- +object(stdClass)#%d (1) { ["a"]=> array(1) { [0]=> - &object(stdClass)#1 (1) { - ["a"]=> - array(1) { - [0]=> - *RECURSION* - } - } + *RECURSION* } } int(2) diff --git a/Zend/tests/gc_007.phpt b/Zend/tests/gc_007.phpt index 1a45ecf1ed..8601ea43b1 100644 --- a/Zend/tests/gc_007.phpt +++ b/Zend/tests/gc_007.phpt @@ -17,10 +17,7 @@ array(1) { [0]=> &array(1) { [0]=> - &array(1) { - [0]=> - *RECURSION* - } + *RECURSION* } } int(0) diff --git a/Zend/tests/gc_008.phpt b/Zend/tests/gc_008.phpt index e27a6b402c..289d581d60 100644 --- a/Zend/tests/gc_008.phpt +++ b/Zend/tests/gc_008.phpt @@ -13,13 +13,10 @@ unset($a); var_dump(gc_collect_cycles()); echo "ok\n" ?> ---EXPECT-- -object(stdClass)#2 (1) { +--EXPECTF-- +object(stdClass)#%d (1) { ["a"]=> - object(stdClass)#2 (1) { - ["a"]=> - *RECURSION* - } + *RECURSION* } int(0) int(1) diff --git a/Zend/tests/gc_009.phpt b/Zend/tests/gc_009.phpt index fe703107ae..263d31f45b 100644 --- a/Zend/tests/gc_009.phpt +++ b/Zend/tests/gc_009.phpt @@ -14,18 +14,12 @@ unset($a); var_dump(gc_collect_cycles()); echo "ok\n" ?> ---EXPECT-- -object(stdClass)#1 (1) { +--EXPECTF-- +object(stdClass)#%d (1) { ["a"]=> array(1) { [0]=> - &object(stdClass)#1 (1) { - ["a"]=> - array(1) { - [0]=> - *RECURSION* - } - } + *RECURSION* } } int(0) diff --git a/Zend/tests/gc_010.phpt b/Zend/tests/gc_010.phpt index d08da356a2..af2dda3fe1 100644 --- a/Zend/tests/gc_010.phpt +++ b/Zend/tests/gc_010.phpt @@ -17,10 +17,7 @@ array(1) { [0]=> &array(1) { [0]=> - &array(1) { - [0]=> - *RECURSION* - } + *RECURSION* } } int(1) diff --git a/Zend/tests/gc_011.phpt b/Zend/tests/gc_011.phpt index bcaf21e4d8..9c4cc2cc0e 100644 --- a/Zend/tests/gc_011.phpt +++ b/Zend/tests/gc_011.phpt @@ -17,13 +17,10 @@ unset($a); var_dump(gc_collect_cycles()); echo "ok\n" ?> ---EXPECT-- -object(Foo)#1 (1) { +--EXPECTF-- +object(Foo)#%d (1) { ["a"]=> - object(Foo)#1 (1) { - ["a"]=> - *RECURSION* - } + *RECURSION* } __destruct int(1) diff --git a/Zend/tests/objects_020.phpt b/Zend/tests/objects_020.phpt index b7c709f320..14e34b9155 100644 --- a/Zend/tests/objects_020.phpt +++ b/Zend/tests/objects_020.phpt @@ -13,18 +13,10 @@ $$test->a->b[] = 2; var_dump($$test); ?> ---EXPECT-- -object(stdClass)#1 (2) { +--EXPECTF-- +object(stdClass)#%d (2) { ["a"]=> - &object(stdClass)#1 (2) { - ["a"]=> - *RECURSION* - ["b"]=> - array(1) { - [0]=> - int(2) - } - } + *RECURSION* ["b"]=> array(1) { [0]=> diff --git a/ext/standard/tests/array/array_map_variation2.phpt b/ext/standard/tests/array/array_map_variation2.phpt index e9608438f2..16561abffc 100644 --- a/ext/standard/tests/array/array_map_variation2.phpt +++ b/ext/standard/tests/array/array_map_variation2.phpt @@ -47,16 +47,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } } array(4) { @@ -94,16 +85,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } } } @@ -127,16 +109,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } } array(4) { @@ -166,16 +139,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } } } @@ -195,16 +159,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } } array(4) { @@ -240,16 +195,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } [1]=> &array(4) { @@ -260,16 +206,7 @@ array(4) { [0]=> &string(2) "v1" [1]=> - &array(4) { - ["k1"]=> - &string(2) "v1" - ["k2"]=> - string(2) "v2" - [0]=> - &string(2) "v1" - [1]=> - *RECURSION* - } + *RECURSION* } } } diff --git a/ext/standard/tests/array/array_push_variation4.phpt b/ext/standard/tests/array/array_push_variation4.phpt index ed339204f4..f8f89042aa 100644 --- a/ext/standard/tests/array/array_push_variation4.phpt +++ b/ext/standard/tests/array/array_push_variation4.phpt @@ -104,28 +104,7 @@ array(10) { [8]=> &string(1) "z" [9]=> - &array(10) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - &string(1) "a" - [4]=> - &string(1) "b" - [5]=> - &string(1) "c" - [6]=> - &string(1) "x" - [7]=> - &string(1) "y" - [8]=> - &string(1) "z" - [9]=> - *RECURSION* - } + *RECURSION* } } Done diff --git a/ext/standard/tests/array/array_values_variation4.phpt b/ext/standard/tests/array/array_values_variation4.phpt index 25980663e7..9c35331fdd 100644 --- a/ext/standard/tests/array/array_values_variation4.phpt +++ b/ext/standard/tests/array/array_values_variation4.phpt @@ -93,23 +93,7 @@ array(4) { int(3) } [0]=> - &array(4) { - ["zero"]=> - string(4) "zero" - ["un"]=> - string(3) "one" - ["sub"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - [0]=> - *RECURSION* - } + *RECURSION* } } -Done \ No newline at end of file +Done diff --git a/ext/standard/tests/array/natcasesort_variation7.phpt b/ext/standard/tests/array/natcasesort_variation7.phpt index c038f7d1c5..91be7e262f 100644 --- a/ext/standard/tests/array/natcasesort_variation7.phpt +++ b/ext/standard/tests/array/natcasesort_variation7.phpt @@ -44,18 +44,7 @@ array(5) { [3]=> string(1) "2" [4]=> - &array(5) { - [0]=> - int(1) - [1]=> - float(3) - [2]=> - string(4) "zero" - [3]=> - string(1) "2" - [4]=> - *RECURSION* - } + *RECURSION* } } bool(true) @@ -75,22 +64,11 @@ array(5) { [1]=> float(3) [4]=> - &array(5) { - [0]=> - int(1) - [3]=> - string(1) "2" - [1]=> - float(3) - [4]=> - *RECURSION* - [2]=> - string(4) "zero" - } + *RECURSION* [2]=> string(4) "zero" } [2]=> string(4) "zero" } -Done \ No newline at end of file +Done diff --git a/ext/standard/var.c b/ext/standard/var.c index de321060f8..7e6f6def94 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -116,8 +116,9 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ break; case IS_ARRAY: myht = Z_ARRVAL_PP(struc); - if (myht->nApplyCount > 1) { + if (++myht->nApplyCount > 1) { PUTS("*RECURSION*\n"); + --myht->nApplyCount; return; } php_printf("%sarray(%d) {\n", COMMON, zend_hash_num_elements(myht)); @@ -126,8 +127,9 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ goto head_done; case IS_OBJECT: myht = Z_OBJDEBUG_PP(struc, is_temp); - if (myht && myht->nApplyCount > 1) { + if (myht && ++myht->nApplyCount > 1) { PUTS("*RECURSION*\n"); + --myht->nApplyCount; return; } @@ -138,6 +140,7 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ head_done: if (myht) { zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_element_dump_func, 1, level); + --myht->nApplyCount; if (is_temp) { zend_hash_destroy(myht); efree(myht);