Skip to content

Commit 462f216

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) Conflicts: NEWS
2 parents c8673b6 + 0f3977b commit 462f216

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Zend/zend_API.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,12 @@ ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_c
25772577
char *lcname = zend_str_tolower_dup(name, name_len);
25782578
int ret;
25792579

2580-
ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL);
2580+
if (lcname[0] == '\\') {
2581+
ret = zend_hash_add(CG(class_table), lcname+1, name_len, &ce, sizeof(zend_class_entry *), NULL);
2582+
} else {
2583+
ret = zend_hash_add(CG(class_table), lcname, name_len+1, &ce, sizeof(zend_class_entry *), NULL);
2584+
}
2585+
25812586
efree(lcname);
25822587
if (ret == SUCCESS) {
25832588
ce->refcount++;

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,15 +1399,8 @@ ZEND_FUNCTION(class_alias)
13991399
return;
14001400
}
14011401

1402-
if (!autoload) {
1403-
lc_name = do_alloca(class_name_len + 1, use_heap);
1404-
zend_str_tolower_copy(lc_name, class_name, class_name_len);
1402+
found = zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &ce TSRMLS_CC);
14051403

1406-
found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
1407-
free_alloca(lc_name, use_heap);
1408-
} else {
1409-
found = zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC);
1410-
}
14111404
if (found == SUCCESS) {
14121405
if ((*ce)->type == ZEND_USER_CLASS) {
14131406
if (zend_register_class_alias_ex(alias_name, alias_name_len, *ce TSRMLS_CC) == SUCCESS) {

0 commit comments

Comments
 (0)