Skip to content

Commit 9343f87

Browse files
committed
Fix identical comparison of arrays with references
Also commit a test I forgot.
1 parent f1e1231 commit 9343f87

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Identical comparison of array with references
3+
--FILE--
4+
<?php
5+
6+
$foo = 42;
7+
$array1 = [&$foo];
8+
$array2 = [$foo];
9+
var_dump($array1 === $array2);
10+
11+
?>
12+
--EXPECT--
13+
bool(true)

Zend/tests/throw_reference.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Throw reference
3+
--FILE--
4+
<?php
5+
6+
$e = new Exception;
7+
$ref =& $e;
8+
throw $e;
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Uncaught exception 'Exception' in %s:%d
13+
Stack trace:
14+
#0 {main}
15+
thrown in %s on line %d

Zend/zend_operators.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,8 @@ static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */
18901890
* whereas this comparison function is expected to return 0 on identity,
18911891
* and non zero otherwise.
18921892
*/
1893+
ZVAL_DEREF(z1);
1894+
ZVAL_DEREF(z2);
18931895
if (is_identical_function(&result, z1, z2 TSRMLS_CC)==FAILURE) {
18941896
return 1;
18951897
}

0 commit comments

Comments
 (0)