Fix bug #68262: Broken reference across cloned objects

This commit is contained in:
Nikita Popov 2014-10-19 13:21:51 +02:00
parent d0151cfe00
commit 4b892439e6
2 changed files with 26 additions and 1 deletions

24
Zend/tests/bug68262.phpt Normal file
View 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"

View File

@ -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) {