From bc4d0082d682513770c99c15a4053f1411e79d73 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Mon, 24 Nov 2003 20:47:53 +0000 Subject: - Fix newly introduced bug which stopped class constants from working. - Thanks to Jan Lehnardt for reporting it. --- Zend/zend_constants.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Zend/zend_constants.c') 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) { -- cgit v1.2.1