]> granicus.if.org Git - php/commitdiff
Fix identical comparison of arrays with references
authorNikita Popov <nikic@php.net>
Fri, 9 May 2014 13:46:43 +0000 (15:46 +0200)
committerNikita Popov <nikic@php.net>
Fri, 9 May 2014 13:46:43 +0000 (15:46 +0200)
Also commit a test I forgot.

Zend/tests/array_with_refs_identical.phpt [new file with mode: 0644]
Zend/tests/throw_reference.phpt [new file with mode: 0644]
Zend/zend_operators.c

diff --git a/Zend/tests/array_with_refs_identical.phpt b/Zend/tests/array_with_refs_identical.phpt
new file mode 100644 (file)
index 0000000..a7c6567
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Identical comparison of array with references
+--FILE--
+<?php
+
+$foo = 42;
+$array1 = [&$foo];
+$array2 = [$foo];
+var_dump($array1 === $array2);
+
+?>
+--EXPECT--
+bool(true)
diff --git a/Zend/tests/throw_reference.phpt b/Zend/tests/throw_reference.phpt
new file mode 100644 (file)
index 0000000..f02eaa6
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Throw reference
+--FILE--
+<?php
+
+$e = new Exception;
+$ref =& $e;
+throw $e;
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' in %s:%d
+Stack trace:
+#0 {main}
+  thrown in %s on line %d
index 4093a8adea2e39e2873a4b6211787b99ddcc37f5..9cf0497d220efcf87aa6ad4f3a783098878d818c 100644 (file)
@@ -1890,6 +1890,8 @@ static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */
         * whereas this comparison function is expected to return 0 on identity,
         * and non zero otherwise.
         */
+       ZVAL_DEREF(z1);
+       ZVAL_DEREF(z2);
        if (is_identical_function(&result, z1, z2 TSRMLS_CC)==FAILURE) {
                return 1;
        }