Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix bug #65579 (Using traits with get_class_methods causes segfault). #423

Merged
merged 1 commit into from

2 participants

@LawnGnome

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.

@LawnGnome LawnGnome 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.
72027cd
@php-pulls php-pulls merged commit 72027cd into php:PHP-5.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 29, 2013
  1. @LawnGnome

    Fix bug #65579 (Using traits with get_class_methods causes segfault).

    LawnGnome authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 8 deletions.
  1. +2 −0  NEWS
  2. +29 −0 Zend/tests/bug65579.phpt
  3. +9 −8 Zend/zend_API.c
View
2  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
View
29 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"
+}
View
17 Zend/zend_API.c
@@ -3917,15 +3917,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;
Something went wrong with that request. Please try again.