mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fix memory leak in array unpack with refcounted numeric string key
This commit is contained in:
parent
e7de9b2091
commit
260d2acdb4
@ -22,6 +22,13 @@ function gen() {
|
||||
}
|
||||
var_dump([...gen()]);
|
||||
|
||||
// Same as previous, but with refcounted string.
|
||||
function gen2() {
|
||||
$foo = "2";
|
||||
yield "4" . $foo => 42;
|
||||
}
|
||||
var_dump([...gen2()]);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
array(4) {
|
||||
@ -56,3 +63,7 @@ array(1) {
|
||||
[0]=>
|
||||
int(42)
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(42)
|
||||
}
|
||||
|
@ -6060,6 +6060,7 @@ ZEND_VM_C_LABEL(add_unpack_again):
|
||||
zend_hash_update(result_ht, Z_STR(key), val);
|
||||
zval_ptr_dtor_str(&key);
|
||||
} else {
|
||||
zval_ptr_dtor(&key);
|
||||
if (!zend_hash_next_index_insert(result_ht, val)) {
|
||||
zend_cannot_add_element();
|
||||
zval_ptr_dtor_nogc(val);
|
||||
|
@ -2609,6 +2609,7 @@ add_unpack_again:
|
||||
zend_hash_update(result_ht, Z_STR(key), val);
|
||||
zval_ptr_dtor_str(&key);
|
||||
} else {
|
||||
zval_ptr_dtor(&key);
|
||||
if (!zend_hash_next_index_insert(result_ht, val)) {
|
||||
zend_cannot_add_element();
|
||||
zval_ptr_dtor_nogc(val);
|
||||
|
Loading…
Reference in New Issue
Block a user