From: Dmitry Stogov Date: Thu, 29 Aug 2013 07:16:56 +0000 (+0400) Subject: Fixed bug #61759 (class_alias() should accept classes with leading backslashes).... X-Git-Tag: php-5.4.20RC1~4^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfc6feb6e84f27094e6a2e3947caa094f7c35d26;p=php Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 620a8f0a27..125a1a2564 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2514,7 +2514,12 @@ ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_c char *lcname = zend_str_tolower_dup(name, name_len); int ret; - ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL); + if (lcname[0] == '\\') { + ret = zend_hash_add(CG(class_table), lcname+1, name_len, &ce, sizeof(zend_class_entry *), NULL); + } else { + ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL); + } + efree(lcname); if (ret == SUCCESS) { ce->refcount++; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 72d905848a..04f4ebec26 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1399,15 +1399,8 @@ ZEND_FUNCTION(class_alias) return; } - if (!autoload) { - lc_name = do_alloca(class_name_len + 1, use_heap); - zend_str_tolower_copy(lc_name, class_name, class_name_len); + found = zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &ce TSRMLS_CC); - found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce); - free_alloca(lc_name, use_heap); - } else { - found = zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC); - } if (found == SUCCESS) { if ((*ce)->type == ZEND_USER_CLASS) { if (zend_register_class_alias_ex(alias_name, alias_name_len, *ce TSRMLS_CC) == SUCCESS) {