cvs: ZendEngine2 / zend_object_handlers.c
| From: | Stanislav Malyshev | Date: | Wed, 09 Oct 2002 17:14:26 +0000 |
| Subject: | cvs: ZendEngine2 / zend_object_handlers.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-482@lists.php.net to get a copy of this message | ||
stas Wed Oct 9 13:14:26 2002 EDT
Modified files:
/ZendEngine2 zend_object_handlers.c
Log:
Fix object write handler behaviour:
* If this value is already set to given value, don't try to set it again.
* If we have reference, we should not move it.
* If we are assigning referenced variable, we should separate it.
# Hope this covers all... Sigh...
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.16 ZendEngine2/zend_object_handlers.c:1.17
--- ZendEngine2/zend_object_handlers.c:1.16 Wed Oct 9 10:21:40 2002
+++ ZendEngine2/zend_object_handlers.c Wed Oct 9 13:14:25 2002
@@ -207,14 +207,17 @@
}
if (zend_hash_find(zobj->properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **)
&variable_ptr) == SUCCESS) {
- if (*variable_ptr == EG(error_zval_ptr) || member == EG(error_zval_ptr)) {
- /* variable_ptr = EG(uninitialized_zval_ptr); */
-/* } else if (variable_ptr==&EG(uninitialized_zval) || variable_ptr!=value_ptr) { */
- } else if (*variable_ptr != value) {
- (*variable_ptr)->refcount--;
- if ((*variable_ptr)->refcount == 0) {
- zendi_zval_dtor(**variable_ptr);
- FREE_ZVAL(*variable_ptr);
+ if(*variable_ptr == value) {
+ /* if we already have this value there, we don't actually need to do anything */
+ setter_done = 1;
+ } else {
+ /* if we are assigning reference, we shouldn't move it, but instead assign variable
+ to the same pointer */
+ if (PZVAL_IS_REF(*variable_ptr)) {
+ (*variable_ptr)->type = value->type;
+ (*variable_ptr)->value = value->value;
+ zval_copy_ctor(*variable_ptr);
+ setter_done = 1;
}
}
} else {
@@ -229,7 +232,12 @@
}
if (!setter_done) {
- value->refcount++;
+ /* if we assign referenced variable, we should separate it */
+ if (PZVAL_IS_REF(value)) {
+ SEPARATE_ZVAL(&value);
+ } else {
+ value->refcount++;
+ }
zend_hash_update(zobj->properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, &value,
sizeof(zval *), NULL);
}
if (member == &tmp_member) {