summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2013-08-29 05:40:23 -0700
committerChristopher Jones <sixd@php.net>2013-08-29 05:40:23 -0700
commit5bff1286b626aff4ebadf74dd55e111a580da90e (patch)
tree56dd613af044ab9ef6f39ed02cb464fbb36e3f79
parent1fdcc705a4bc3a9d42a32c5f1ee1ce6b5d3ce428 (diff)
parentdfc6feb6e84f27094e6a2e3947caa094f7c35d26 (diff)
downloadphp-git-5bff1286b626aff4ebadf74dd55e111a580da90e.tar.gz
Merge branch 'PHP-5.4' of https://git.php.net/repository/php-src into PHP-5.4
* 'PHP-5.4' of https://git.php.net/repository/php-src: Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) Fixed bug #61759 (class_alias() should accept classes with leading backslashes). (Julien) Avoid compiler warning Fix bug #65579 (Using traits with get_class_methods causes segfault).
-rw-r--r--NEWS4
-rw-r--r--Zend/tests/bug65579.phpt29
-rw-r--r--Zend/zend_API.c24
-rw-r--r--Zend/zend_builtin_functions.c9
4 files changed, 49 insertions, 17 deletions
diff --git a/NEWS b/NEWS
index 093fa20626..6169cd0902 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
?? ??? 2013, PHP 5.4.20
- Core:
+ . Fixed bug #65579 (Using traits with get_class_methods causes segfault).
+ (Adam)
. Fixed bug #65490 (Duplicate calls to get lineno & filename for
DTRACE_FUNCTION_*). (Chris Jones)
. Fixed bug #65483 (quoted-printable encode stream filter incorrectly encoding
@@ -18,6 +20,8 @@ PHP NEWS
. Fixed bug #65225 (PHP_BINARY incorrectly set). (Patrick Allaert)
. Improved fix for bug #63186 (compile failure on netbsd). (Matteo)
. Fixed bug #62692 (PHP fails to build with DTrace). (Chris Jones, Kris Van Hees)
+ . Fixed bug #61759 (class_alias() should accept classes with leading
+ backslashes). (Julien)
. Fixed bug #61345 (CGI mode - make install don't work). (Michael Heimpold)
. Cherry-picked some DTrace build commits (allowing builds on Linux,
bug #62691, and bug #63706) from PHP 5.5 branch
diff --git a/Zend/tests/bug65579.phpt b/Zend/tests/bug65579.phpt
new file mode 100644
index 0000000000..25d74ed4f5
--- /dev/null
+++ b/Zend/tests/bug65579.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #65579 (Using traits with get_class_methods causes segfault)
+--FILE--
+<?php
+trait ParentTrait {
+ public function testMethod() { }
+}
+
+trait ChildTrait {
+ use ParentTrait {
+ testMethod as testMethodFromParentTrait;
+ }
+ public function testMethod() { }
+}
+
+class TestClass {
+ use ChildTrait;
+}
+
+$obj = new TestClass();
+var_dump(get_class_methods($obj));
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(10) "testMethod"
+ [1]=>
+ string(25) "testmethodfromparenttrait"
+}
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 90d27b7987..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++;
@@ -3917,15 +3922,16 @@ ZEND_API const char* zend_find_alias_name(zend_class_entry *ce, const char *name
{
zend_trait_alias *alias, **alias_ptr;
- alias_ptr = ce->trait_aliases;
- alias = *alias_ptr;
- while (alias) {
- if (alias->alias_len == len &&
- !strncasecmp(name, alias->alias, alias->alias_len)) {
- return alias->alias;
- }
- alias_ptr++;
+ if ((alias_ptr = ce->trait_aliases)) {
alias = *alias_ptr;
+ while (alias) {
+ if (alias->alias_len == len &&
+ !strncasecmp(name, alias->alias, alias->alias_len)) {
+ return alias->alias;
+ }
+ alias_ptr++;
+ alias = *alias_ptr;
+ }
}
return name;
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) {