Skip to content

Commit 6bf8ff6

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79930
2 parents 9d9fa32 + da786a2 commit 6bf8ff6

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
. Fixed bug #73060 (php failed with error after temp folder cleaned up).
1818
(cmb)
1919

20+
- Standard:
21+
. Fixed bug #79930 (array_merge_recursive() crashes when called with array
22+
with single reference). (Nikita)
23+
2024
06 Aug 2020, PHP 7.4.9
2125

2226
- Apache:

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,7 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
36433643
return 0;
36443644
}
36453645
} else {
3646-
Z_TRY_ADDREF_P(src_entry);
3646+
Z_TRY_ADDREF_P(src_zval);
36473647
zend_hash_next_index_insert(Z_ARRVAL_P(dest_zval), src_zval);
36483648
}
36493649
zval_ptr_dtor(&tmp);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #79930: array_merge_recursive() crashes when called with array with single reference
3+
--FILE--
4+
<?php
5+
6+
$a = 'a';
7+
$array = [
8+
'value' => $a . 'b',
9+
];
10+
11+
// Create rc=1 reference.
12+
array_walk($array, function () {});
13+
14+
$m = array_merge_recursive(['value' => 'a'], $array);
15+
16+
var_dump($a, $array, $m);
17+
18+
?>
19+
--EXPECT--
20+
string(1) "a"
21+
array(1) {
22+
["value"]=>
23+
string(2) "ab"
24+
}
25+
array(1) {
26+
["value"]=>
27+
array(2) {
28+
[0]=>
29+
string(1) "a"
30+
[1]=>
31+
string(2) "ab"
32+
}
33+
}

0 commit comments

Comments
 (0)