mirror of
https://github.com/php/php-src.git
synced 2024-11-27 20:03:40 +08:00
Fixed bug #79477
Make sure to deindirect properties when creating array.
This commit is contained in:
parent
c4cdf1ae12
commit
79a36ff7f3
1
NEWS
1
NEWS
@ -5,6 +5,7 @@ PHP NEWS
|
||||
- Core:
|
||||
. Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference
|
||||
on !CS constant). (Nikita)
|
||||
. Fixed bug #79477 (casting object into array creates references). (Nikita)
|
||||
|
||||
- DOM:
|
||||
. Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).
|
||||
|
20
Zend/tests/bug79477.phpt
Normal file
20
Zend/tests/bug79477.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #79477: casting object into array creates references
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Test {
|
||||
public $prop = 'default value';
|
||||
}
|
||||
|
||||
$obj = new Test;
|
||||
$obj->{1} = null;
|
||||
|
||||
$arr = (array) $obj;
|
||||
$arr['prop'] = 'new value';
|
||||
|
||||
echo $obj->prop, "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
default value
|
@ -2722,7 +2722,7 @@ convert:
|
||||
{
|
||||
HashTable *new_ht = zend_new_array(zend_hash_num_elements(ht));
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) {
|
||||
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, str_key, zv) {
|
||||
do {
|
||||
if (Z_OPT_REFCOUNTED_P(zv)) {
|
||||
if (Z_ISREF_P(zv) && Z_REFCOUNT_P(zv) == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user