mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fixed bug #79930
We're inserting src_zval, so that's what we should addref.
This commit is contained in:
parent
12db8b90a7
commit
da786a22af
4
NEWS
4
NEWS
@ -17,6 +17,10 @@ PHP NEWS
|
||||
. Fixed bug #73060 (php failed with error after temp folder cleaned up).
|
||||
(cmb)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #79930 (array_merge_recursive() crashes when called with array
|
||||
with single reference). (Nikita)
|
||||
|
||||
06 Aug 2020, PHP 7.3.21
|
||||
|
||||
- Apache:
|
||||
|
@ -3615,7 +3615,7 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
Z_TRY_ADDREF_P(src_entry);
|
||||
Z_TRY_ADDREF_P(src_zval);
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(dest_zval), src_zval);
|
||||
}
|
||||
zval_ptr_dtor(&tmp);
|
||||
|
33
ext/standard/tests/array/bug79930.phpt
Normal file
33
ext/standard/tests/array/bug79930.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Bug #79930: array_merge_recursive() crashes when called with array with single reference
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = 'a';
|
||||
$array = [
|
||||
'value' => $a . 'b',
|
||||
];
|
||||
|
||||
// Create rc=1 reference.
|
||||
array_walk($array, function () {});
|
||||
|
||||
$m = array_merge_recursive(['value' => 'a'], $array);
|
||||
|
||||
var_dump($a, $array, $m);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "a"
|
||||
array(1) {
|
||||
["value"]=>
|
||||
string(2) "ab"
|
||||
}
|
||||
array(1) {
|
||||
["value"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
[1]=>
|
||||
string(2) "ab"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user