]> granicus.if.org Git - php/commitdiff
- Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection)
authorFelipe Pena <felipe@php.net>
Fri, 2 Apr 2010 21:44:09 +0000 (21:44 +0000)
committerFelipe Pena <felipe@php.net>
Fri, 2 Apr 2010 21:44:09 +0000 (21:44 +0000)
NEWS
Zend/tests/bug35239.phpt
ext/standard/tests/array/array_map_variation2.phpt
ext/standard/tests/array/array_push_variation4.phpt
ext/standard/tests/array/array_values_variation4.phpt
ext/standard/tests/array/natcasesort_variation7.phpt
ext/standard/var.c

diff --git a/NEWS b/NEWS
index a3b7e7f3257a1a1c428dd6b645c049a6b16035e8..7d8924bcaca73229ca07f52e6e1dd7c63ca16a18 100644 (file)
--- 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 #51393 (DateTime::createFromFormat() fails if format string contains
   timezone). (Adam)
 - Fixed bug #51338 (URL-Rewriter is still enabled if use_only_cookies is
index 7fc7b7d3b630ea02ed24e248adfbafbaa8535791..869971e2a26b70ddb63d477129aca58bc047f35f 100755 (executable)
@@ -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
index 6cd0096b681f1675b79577203edd9af2dff2dde4..9a061549805c828a5c56a426c44e3a31389b9b54 100644 (file)
@@ -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*
     }
   }
 }
index 1048d80cf209cd83184035c4596f7a68c893fafd..d6a774ad710a06eee35343a46971e82c08dd74c1 100644 (file)
@@ -107,28 +107,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
index 199d23dc93b2afe615d67e2889b81b5487d02d0c..ad541175f5edd98d90ae5d4065bf215e4753c2e5 100644 (file)
@@ -96,23 +96,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
index eefcd1d6f6cfa793b1f316abc1db79ff9e176fa6..8b94f3fa53a571d2be2ccb23df147cb8fba0a9d9 100644 (file)
@@ -46,18 +46,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)
@@ -77,18 +66,7 @@ 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"
   }
index 15d0ab55c7e706f239b15e687096b844c377d09b..d52c48b94340bcd60c9e8646f2fd428d69c6caca 100644 (file)
@@ -124,8 +124,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));
@@ -133,8 +134,9 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC)
                goto head_done;
        case IS_OBJECT:
                myht = Z_OBJPROP_PP(struc);
-               if (myht && myht->nApplyCount > 1) {
+               if (myht && ++myht->nApplyCount > 1) {
                        PUTS("*RECURSION*\n");
+                       --myht->nApplyCount;
                        return;
                }
 
@@ -145,6 +147,7 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC)
 head_done:
                if (myht) {
                        zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_element_dump_func, 1, level);
+                       --myht->nApplyCount;
                }
                if (level > 1) {
                        php_printf("%*c", level-1, ' ');