com php-src: Fixed reference support (references to references are not allowed): Zend/zend_object_handlers.c
| From: | Dmitry Stogov | Date: | Thu, 14 Aug 2014 13:00:01 +0000 |
| Subject: | com php-src: Fixed reference support (references to references are not allowed): Zend/zend_object_handlers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79860@lists.php.net to get a copy of this message | ||
Commit: 05ca575bbb20ca2905f2ebc33044b0111e9700bd
Author: Dmitry Stogov <dmitry@zend.com> Thu, 14 Aug 2014 17:00:01 +0400
Parents: e430948581ed849c74bc87504a99a2c8a97b8c1d
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=05ca575bbb20ca2905f2ebc33044b0111e9700bd
Log:
Fixed reference support (references to references are not allowed)
Changed paths:
M Zend/zend_object_handlers.c
Diff:
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index ff8d99a..6f0dc78 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -593,10 +593,24 @@ found:
ZVAL_COPY_VALUE(&garbage, Z_REFVAL_P(variable_ptr)); /* old value should be destroyed */
/* To check: can't *variable_ptr be some system variable like error_zval here? */
- ZVAL_COPY_VALUE(Z_REFVAL_P(variable_ptr), value);
- if (Z_REFCOUNTED_P(value) && Z_REFCOUNT_P(value) > 0) {
- zval_copy_ctor(Z_REFVAL_P(variable_ptr));
+ if (UNEXPECTED(Z_REFCOUNTED_P(value))) {
+ if (EXPECTED(!Z_ISREF_P(value))) {
+ Z_ADDREF_P(value);
+ } else {
+ if (Z_REFCOUNT_P(value) == 1) {
+ ZVAL_UNREF(value);
+ } else {
+ value = Z_REFVAL_P(value);
+ }
+ if (Z_REFCOUNTED_P(value)) {
+ if (UNEXPECTED(Z_REFVAL_P(variable_ptr) == value)) {
+ goto exit;
+ }
+ Z_ADDREF_P(value);
+ }
+ }
}
+ ZVAL_COPY_VALUE(Z_REFVAL_P(variable_ptr), value);
zval_ptr_dtor(&garbage);
} else {
zval garbage;