mirror of
https://github.com/php/php-src.git
synced 2024-09-24 11:27:28 +00:00
Merge branch 'PHP-7.0'
This commit is contained in:
commit
494bf962a6
@ -2967,6 +2967,10 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
|
||||
if (Z_TYPE_P(dest_zval) == IS_NULL) {
|
||||
convert_to_array_ex(dest_zval);
|
||||
add_next_index_null(dest_zval);
|
||||
} else if (Z_TYPE_P(dest_zval) == IS_ARRAY) {
|
||||
if (UNEXPECTED(Z_ARRVAL_P(dest_zval)->nNextFreeElement > Z_ARRVAL_P(dest_zval)->nNumUsed)) {
|
||||
Z_ARRVAL_P(dest_zval)->nNextFreeElement = Z_ARRVAL_P(dest_zval)->nNumUsed;
|
||||
}
|
||||
} else {
|
||||
convert_to_array_ex(dest_zval);
|
||||
}
|
||||
|
23
ext/standard/tests/array/bug70808.phpt
Normal file
23
ext/standard/tests/array/bug70808.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Bug #70808 (array_merge_recursive corrupts memory of unset items)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$arr1 = array("key" => array(0, 1));
|
||||
$arr2 = array("key" => array(2));
|
||||
|
||||
unset($arr1["key"][1]);
|
||||
|
||||
$result = array_merge_recursive($arr1, $arr2);
|
||||
print_r($result);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[key] => Array
|
||||
(
|
||||
[0] => 0
|
||||
[1] => 2
|
||||
)
|
||||
|
||||
)
|
Loading…
Reference in New Issue
Block a user