]> granicus.if.org Git - php/commitdiff
Fixed bug #61759 (class_alias() should accept classes with leading backslashes)....
authorDmitry Stogov <dmitry@zend.com>
Thu, 29 Aug 2013 07:16:56 +0000 (11:16 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 29 Aug 2013 07:16:56 +0000 (11:16 +0400)
Zend/zend_API.c
Zend/zend_builtin_functions.c

index 620a8f0a27ce1a6f30add0ec1eceeeadf2aa06d4..125a1a2564793fd70aef13cb9d94ba24e834d650 100644 (file)
@@ -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++;
index 72d905848a1b1a24383aae88152e4488ec302a79..04f4ebec26ab045d6c339903a9bbc066941bd280 100644 (file)
@@ -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) {