Browse Source

Fix identical comparison of arrays with references

Also commit a test I forgot.
pull/673/head
Nikita Popov 12 years ago
parent
commit
9343f874cd
  1. 13
      Zend/tests/array_with_refs_identical.phpt
  2. 15
      Zend/tests/throw_reference.phpt
  3. 2
      Zend/zend_operators.c

13
Zend/tests/array_with_refs_identical.phpt

@ -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)

15
Zend/tests/throw_reference.phpt

@ -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

2
Zend/zend_operators.c

@ -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;
}

Loading…
Cancel
Save