com php-src: Fix bug #65579 (Using traits with get_class_me thods causes segfault).: Zend/tests/bug6557 9.phpt Zend/zend_API.c

From: Date: Wed, 16 Oct 2013 08:18:36 +0000
Subject: com php-src: Fix bug #65579 (Using traits with get_class_me thods causes segfault).: Zend/tests/bug6557 9.phpt Zend/zend_API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-73557@lists.php.net to get a copy of this message
Commit: acbfd16ddf6540d21d61ad4672e64d803fa5824b Author: Adam Harvey <aharvey@php.net> Wed, 28 Aug 2013 20:33:42 -0700 Committer: Anatol Belski <ab@php.net> Wed, 16 Oct 2013 01:18:36 -0700 Parents: 132505cd526fcb5a3458cf41fa266f976247ed17 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=acbfd16ddf6540d21d61ad4672e64d803fa5824b Log: Fix bug #65579 (Using traits with get_class_methods causes segfault). Specifically, this checks if there are trait aliases defined in the class scope before attempting to dereference the first trait alias. This handles the case where a trait alias was used in a child trait but no aliases exist in the concrete class.. Bugs: https://bugs.php.net/65579 Changed paths: A Zend/tests/bug65579.phpt M Zend/zend_API.c Diff: diff --git a/Zend/tests/bug65579.phpt b/Zend/tests/bug65579.phpt new file mode 100644 index 0000000..25d74ed --- /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 772c0f3..421cc3f 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -4011,15 +4011,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;

« previous php.cvs (#73557) next »