Skip to content

Commit 0f3977b

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: 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 94816ed + dfc6feb commit 0f3977b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
--enable-dtrace). (Chris Jones, Kris Van Hees)
1313
. Fixed bug #65225 (PHP_BINARY incorrectly set). (Patrick Allaert)
1414
. Fixed bug #62692 (PHP fails to build with DTrace). (Chris Jones, Kris Van Hees)
15+
. Fixed bug #61759 (class_alias() should accept classes with leading
16+
backslashes). (Julien)
1517
. Fixed bug #46311 (Pointer aliasing issue results in miscompile on gcc4.4).
1618
(Nikita Popov)
1719

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)