mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
Fix bug #68262: Broken reference across cloned objects
This commit is contained in:
parent
d0151cfe00
commit
4b892439e6
24
Zend/tests/bug68262.phpt
Normal file
24
Zend/tests/bug68262.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
Bug #68262: Broken reference across cloned objects
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class C {
|
||||
public $p;
|
||||
}
|
||||
|
||||
$first = new C;
|
||||
$first->p = 'init';
|
||||
|
||||
$clone = clone $first;
|
||||
$ref =& $first->p;
|
||||
unset($ref);
|
||||
|
||||
$clone = clone $first;
|
||||
$clone->p = 'foo';
|
||||
|
||||
var_dump($first->p);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(4) "init"
|
@ -144,7 +144,8 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o
|
||||
if (old_object->ce->default_properties_count) {
|
||||
for (i = 0; i < old_object->ce->default_properties_count; i++) {
|
||||
zval_ptr_dtor(&new_object->properties_table[i]);
|
||||
ZVAL_COPY(&new_object->properties_table[i], &old_object->properties_table[i]);
|
||||
ZVAL_COPY_VALUE(&new_object->properties_table[i], &old_object->properties_table[i]);
|
||||
zval_add_ref(&new_object->properties_table[i]);
|
||||
}
|
||||
}
|
||||
if (old_object->properties) {
|
||||
|
Loading…
Reference in New Issue
Block a user