]> granicus.if.org Git - php/commitdiff
Added test for bug #45312
authorDmitry Stogov <dmitry@php.net>
Thu, 19 Jun 2008 12:09:44 +0000 (12:09 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 19 Jun 2008 12:09:44 +0000 (12:09 +0000)
ext/standard/tests/array/bug45312.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/array/bug45312.phpt b/ext/standard/tests/array/bug45312.phpt
new file mode 100644 (file)
index 0000000..017defe
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Bug #45312 (Segmentation fault on second request for array functions)
+--FILE--
+<?php
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+    static function comp_func_cr2($a, $b) {
+       echo ".";
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member < $b->priv_member) ? 1 : -1;
+    }
+    function dump() {
+        echo $this->priv_member . "\n";
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new cr(4), 2 => new cr(-15),);
+$result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr"));
+foreach($result as $val) {
+       $val->dump();
+}
+$result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr2"));
+foreach($result as $val) {
+       $val->dump();
+}
+?>
+--EXPECT--
+9
+12
+23
+....9
+12
+23