summaryrefslogtreecommitdiff
path: root/Zend/zend_execute_API.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-06-13 16:48:10 +0000
committerDmitry Stogov <dmitry@php.net>2007-06-13 16:48:10 +0000
commit1c7fa8fb4c3c1fb4bcd42a8421c29a1753e5d4bc (patch)
treea67aed95142573086f01b83311024211d9babfcc /Zend/zend_execute_API.c
parent28bc39500a7609531f5277c0bbf40eb273ff321a (diff)
downloadphp-git-1c7fa8fb4c3c1fb4bcd42a8421c29a1753e5d4bc.tar.gz
Fixed bug #41633 (Crash instantiating classes with self-referencing constants)
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r--Zend/zend_execute_API.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index f3a123e390..b57834f395 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -448,6 +448,10 @@ ZEND_API int zend_is_true(zval *op)
#include "../TSRM/tsrm_strtok_r.h"
+#define IS_VISITED_CONSTANT IS_CONSTANT_INDEX
+#define IS_CONSTANT_VISITED(p) (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
+#define MARK_CONSTANT_VISITED(p) Z_TYPE_P(p) |= IS_VISITED_CONSTANT
+
ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC)
{
zval *p = *pp;
@@ -455,13 +459,17 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
zval const_value;
char *colon;
- if (Z_TYPE_P(p) == IS_CONSTANT) {
+ if (IS_CONSTANT_VISITED(p)) {
+ zend_error(E_ERROR, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p));
+ } else if (Z_TYPE_P(p) == IS_CONSTANT) {
int refcount;
zend_uchar is_ref;
SEPARATE_ZVAL_IF_NOT_REF(pp);
p = *pp;
+ MARK_CONSTANT_VISITED(p);
+
refcount = p->refcount;
is_ref = p->is_ref;