summaryrefslogtreecommitdiff
path: root/Zend/zend_API.h
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-07-09 11:57:42 +0400
committerDmitry Stogov <dmitry@zend.com>2014-07-09 11:57:42 +0400
commit1dd07d6bf438a6a60f2fefcdd7e5c45045ef88f9 (patch)
tree9819118878bd35afd815a7aad1ea84da8e6b50bc /Zend/zend_API.h
parentca414c69040c66642b38d9f3aebe343265adc3f5 (diff)
downloadphp-git-1dd07d6bf438a6a60f2fefcdd7e5c45045ef88f9.tar.gz
Partial fix that allows internal constructors to set $this to null.
The address of $this passed to drectly called internal constructor in execute_data->return_value. Internal constructors should use ZEND_CTOR_MAKE_NULL() macro (insted of previous ZEND_NULL(EG(This))) to do the work. This patch doesn't fix the problem for indirectly called constructors. e.g. parant::__construct().
Diffstat (limited to 'Zend/zend_API.h')
-rw-r--r--Zend/zend_API.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index b702bd4138..beca63c50b 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -637,6 +637,27 @@ END_EXTERN_C()
} \
} while (0)
+/* May be used in internal constructors to make them return NULL */
+#if 1 // support for directly called constructors only ???
+#define ZEND_CTOR_MAKE_NULL() do { \
+ if (EG(current_execute_data)->return_value) { \
+ zval_ptr_dtor(EG(current_execute_data)->return_value); \
+ ZVAL_NULL(EG(current_execute_data)->return_value); \
+ } \
+ } while (0)
+#else // attempt to support calls to parent::__construct() ???
+#define ZEND_CTOR_MAKE_NULL() do { \
+ if (EG(current_execute_data)->return_value) { \
+ zval_ptr_dtor(EG(current_execute_data)->return_value); \
+ ZVAL_NULL(EG(current_execute_data)->return_value); \
+ } else if (EG(current_execute_data)->prev_execute_data && \
+ EG(current_execute_data)->prev_execute_data->object == \
+ EG(current_execute_data)->object) { \
+ EG(current_execute_data)->prev_execute_data->object = NULL; \
+ } \
+ } while (0)
+#endif
+
#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p) TSRMLS_CC) : NULL)))