diff options
author | Nikita Popov <nikic@php.net> | 2014-10-19 13:21:51 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2014-10-19 13:22:44 +0200 |
commit | 4b892439e61634b4bdcbf0bd54ef8577575875fd (patch) | |
tree | 4d69bdaa90e6d8ca0750ff013cf65f4acf9ff62c /Zend | |
parent | d0151cfe0073991b3051875ded00bce19ecea009 (diff) | |
download | php-git-4b892439e61634b4bdcbf0bd54ef8577575875fd.tar.gz |
Fix bug #68262: Broken reference across cloned objects
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug68262.phpt | 24 | ||||
-rw-r--r-- | Zend/zend_objects.c | 3 |
2 files changed, 26 insertions, 1 deletions
diff --git a/Zend/tests/bug68262.phpt b/Zend/tests/bug68262.phpt new file mode 100644 index 0000000000..8d009f621e --- /dev/null +++ b/Zend/tests/bug68262.phpt @@ -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" diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 40d37b3d36..58c034163e 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -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) { |