Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  [ci skip] NEWS for GH-16061
  Fix array_merge_recursive(): convert_to_array() may need separation (#16061)
This commit is contained in:
Arnaud Le Blanc 2024-10-02 12:44:00 +02:00
commit 3952a8f9f1
No known key found for this signature in database
GPG key ID: 0098C05DD15ABC13
2 changed files with 30 additions and 1 deletions

View file

@ -4037,7 +4037,6 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
}
ZEND_ASSERT(!Z_ISREF_P(dest_entry) || Z_REFCOUNT_P(dest_entry) > 1);
SEPARATE_ZVAL(dest_entry);
dest_zval = dest_entry;
if (Z_TYPE_P(dest_zval) == IS_NULL) {
@ -4046,6 +4045,8 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
} else {
convert_to_array(dest_zval);
}
SEPARATE_ZVAL(dest_zval);
ZVAL_UNDEF(&tmp);
if (Z_TYPE_P(src_zval) == IS_OBJECT) {
ZVAL_COPY(&tmp, src_zval);

View file

@ -0,0 +1,28 @@
--TEST--
GH-16053: Assertion failure in Zend/zend_hash.c
--FILE--
<?php
class test
{
}
$x = new test;
$arr1 = array("string" => $x);
$arr2 = array("string" => "hello");
var_dump($arr1);
var_dump(array_merge_recursive($arr1, $arr2));
?>
--EXPECTF--
array(1) {
["string"]=>
object(test)#%d (0) {
}
}
array(1) {
["string"]=>
array(1) {
[0]=>
string(5) "hello"
}
}