summaryrefslogtreecommitdiff
path: root/Zend/zend_constants.c
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2003-11-24 20:47:53 +0000
committerAndi Gutmans <andi@php.net>2003-11-24 20:47:53 +0000
commitbc4d0082d682513770c99c15a4053f1411e79d73 (patch)
treeab9aace904aaa0138046fc64548bd2894aa5b7fc /Zend/zend_constants.c
parent77297a2b0177f59b0d71ddbdebf549f1a9ad2b8b (diff)
downloadphp-git-bc4d0082d682513770c99c15a4053f1411e79d73.tar.gz
- Fix newly introduced bug which stopped class constants from working.
- Thanks to Jan Lehnardt for reporting it.
Diffstat (limited to 'Zend/zend_constants.c')
-rw-r--r--Zend/zend_constants.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index 75837e8703..8c9e5c9604 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -223,21 +223,26 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
int const_name_len = name_len - class_name_len - 2;
char *constant_name = colon+2;
zval **ret_constant;
+ char *class_name;
if (EG(in_execution)) {
scope = EG(scope);
} else {
scope = CG(active_class_entry);
}
-
- if (class_name_len == sizeof("self")-1 && strcmp(name, "self") == 0) {
+
+ class_name = do_alloca(class_name_len+1);
+ memcpy(class_name, name, class_name_len);
+ class_name[class_name_len] = '\0';
+
+ if (class_name_len == sizeof("self")-1 && strcmp(class_name, "self") == 0) {
if (scope) {
ce = &scope;
} else {
zend_error(E_ERROR, "Cannot access self:: when no class scope is active");
retval = 0;
}
- } else if (class_name_len == sizeof("parent")-1 && strcmp(name, "parent") == 0) {
+ } else if (class_name_len == sizeof("parent")-1 && strcmp(class_name, "parent") == 0) {
if (!scope) {
zend_error(E_ERROR, "Cannot access parent:: when no class scope is active");
} else if (!scope->parent) {
@@ -246,10 +251,11 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
ce = &scope->parent;
}
} else {
- if (zend_lookup_class(name, class_name_len, &ce TSRMLS_CC) != SUCCESS) {
+ if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) != SUCCESS) {
retval = 0;
}
}
+ free_alloca(class_name);
if (retval && ce) {
if (zend_hash_find(&((*ce)->constants_table), constant_name, const_name_len+1, (void **) &ret_constant) != SUCCESS) {