cvs: ZendEngine2 / zend_constants.c

From: Date: Mon, 24 Nov 2003 20:47:53 +0000
Subject: cvs: ZendEngine2 / zend_constants.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2006@lists.php.net to get a copy of this message
andi Mon Nov 24 15:47:53 2003 EDT Modified files: /ZendEngine2 zend_constants.c Log: - Fix newly introduced bug which stopped class constants from working. - Thanks to Jan Lehnardt for reporting it. Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.61 ZendEngine2/zend_constants.c:1.62 --- ZendEngine2/zend_constants.c:1.61 Mon Nov 24 13:13:29 2003 +++ ZendEngine2/zend_constants.c Mon Nov 24 15:47:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_constants.c,v 1.61 2003/11/24 18:13:29 andi Exp $ */ +/* $Id: zend_constants.c,v 1.62 2003/11/24 20:47:53 andi Exp $ */ #include "zend.h" #include "zend_constants.h" @@ -223,21 +223,26 @@ 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 @@ 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) {

« previous php.zend-engine.cvs (#2006) next »