]> granicus.if.org Git - php/commitdiff
This commit was manufactured by cvs2svn to create branch 'PHP_4_3'.
authorSVN Migration <svn@php.net>
Sun, 11 Jul 2004 21:15:05 +0000 (21:15 +0000)
committerSVN Migration <svn@php.net>
Sun, 11 Jul 2004 21:15:05 +0000 (21:15 +0000)
ext/standard/tests/array/bug28974.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/bug29038.phpt [new file with mode: 0644]
ext/standard/tests/serialize/bug28325.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/array/bug28974.phpt b/ext/standard/tests/array/bug28974.phpt
new file mode 100644 (file)
index 0000000..fb272e1
--- /dev/null
@@ -0,0 +1,89 @@
+--TEST--
+Bug #28974 array_(p)slice() treats large lengths incorrectly - overflow
+--FILE--
+<?php
+$a = $b = $c = array(0,1,2,3,4,5);
+print_r($a);
+// this is ok:
+print_r(array_slice($a,2,2147483645));
+
+// this is wrong:
+print_r(array_slice($a,2,2147483646));
+echo 'print_r(array_splice($a,2,1));'."\n";
+print_r(array_splice($a,2,1));
+echo "\$a is :";
+print_r($a);
+echo 'print_r(array_splice($b,2,2147483645));'."\n";
+print_r(array_splice($b,2,2147483645));
+echo "\$b is :";
+print_r($b);
+
+// this is wrong:
+echo 'print_r(array_splice($c,2,2147483646));'."\n";
+print_r(array_splice($c,2,2147483646));
+echo "\$c is :";
+print_r($c);
+?>
+--EXPECT--
+Array
+(
+    [0] => 0
+    [1] => 1
+    [2] => 2
+    [3] => 3
+    [4] => 4
+    [5] => 5
+)
+Array
+(
+    [0] => 2
+    [1] => 3
+    [2] => 4
+    [3] => 5
+)
+Array
+(
+    [0] => 2
+    [1] => 3
+    [2] => 4
+    [3] => 5
+)
+print_r(array_splice($a,2,1));
+Array
+(
+    [0] => 2
+)
+$a is :Array
+(
+    [0] => 0
+    [1] => 1
+    [2] => 3
+    [3] => 4
+    [4] => 5
+)
+print_r(array_splice($b,2,2147483645));
+Array
+(
+    [0] => 2
+    [1] => 3
+    [2] => 4
+    [3] => 5
+)
+$b is :Array
+(
+    [0] => 0
+    [1] => 1
+)
+print_r(array_splice($c,2,2147483646));
+Array
+(
+    [0] => 2
+    [1] => 3
+    [2] => 4
+    [3] => 5
+)
+$c is :Array
+(
+    [0] => 0
+    [1] => 1
+)
diff --git a/ext/standard/tests/general_functions/bug29038.phpt b/ext/standard/tests/general_functions/bug29038.phpt
new file mode 100644 (file)
index 0000000..8804ffb
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+bug #29038 (extract(), EXTR_PREFIX_SAME option prefixes empty strings)
+--FILE--
+<?php
+function f1() {
+  $c = extract(array("" => 1),EXTR_PREFIX_SAME,"prefix");
+  echo "Extracted:";
+  var_dump($c);
+  print_r(get_defined_vars());
+}
+function f2() {
+  $a = 1;
+  $c = extract(array("a" => 1),EXTR_PREFIX_SAME,"prefix");
+  echo "Extracted:";
+  var_dump($c);
+  print_r(get_defined_vars());
+}
+function f3() {
+  $a = 1;
+  $c = extract(array("a" => 1),EXTR_PREFIX_ALL,"prefix");
+  echo "Extracted:";
+  var_dump($c);
+  print_r(get_defined_vars());
+}
+function f4() {
+  $c = extract(array("" => 1),EXTR_PREFIX_ALL,"prefix");
+  echo "Extracted:";
+  var_dump($c);
+  print_r(get_defined_vars());
+}
+function f5() {
+  $c = extract(array("111" => 1),EXTR_PREFIX_ALL,"prefix");
+  echo "Extracted:";
+  var_dump($c);
+  print_r(get_defined_vars());
+}
+
+f1();
+f2();
+f3();
+f4();
+f5();
+?>
+--EXPECT--
+Extracted:int(0)
+Array
+(
+    [c] => 0
+)
+Extracted:int(1)
+Array
+(
+    [a] => 1
+    [prefix_a] => 1
+    [c] => 1
+)
+Extracted:int(1)
+Array
+(
+    [a] => 1
+    [prefix_a] => 1
+    [c] => 1
+)
+Extracted:int(0)
+Array
+(
+    [c] => 0
+)
+Extracted:int(1)
+Array
+(
+    [prefix_111] => 1
+    [c] => 1
+)
\ No newline at end of file
diff --git a/ext/standard/tests/serialize/bug28325.phpt b/ext/standard/tests/serialize/bug28325.phpt
new file mode 100644 (file)
index 0000000..7f2bd66
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #28325 (Problem in serialisation of circular references)
+--FILE--
+<?php
+class a {
+       public $b;
+}
+class b {
+       public $c;
+}
+class c {
+       public $d;
+}
+$a = new a();
+$a->b = new b();
+$a->b->c = new c();
+$a->b->c->d = $a;
+var_dump(unserialize(serialize($a)));
+?>
+--EXPECTF--
+object(a)#%d (1) {
+  ["b"]=>
+  object(b)#%d (1) {
+    ["c"]=>
+    object(c)#%d (1) {
+      ["d"]=>
+      object(a)#%d (1) {
+        ["b"]=>
+        object(b)#%d (1) {
+          ["c"]=>
+          object(c)#%d (1) {
+            ["d"]=>
+            *RECURSION*
+          }
+        }
+      }
+    }
+  }
+}