Commit: 2ae8d2fbfb8797b1038ad64c267ee0797f977671 Author: Dmitry Stogov <dmi...@zend.com> Mon, 21 May 2012 13:57:41 +0400 Parents: c8f47a8e7c36bf57188b6172ffc0fbc6028f3050 Branches: PHP-5.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2ae8d2fbfb8797b1038ad64c267ee0797f977671 Log: Fixed bug #61998 (Using traits with method aliases appears to result in crash during execution) Bugs: https://bugs.php.net/61998 Changed paths: M NEWS M Zend/zend_compile.c M Zend/zend_opcode.c Diff: diff --git a/NEWS b/NEWS index 1a87234..68f0a35 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ PHP NEWS . Fixed missing bound check in iptcparse(). (chris at chiappa.net) . Fixed bug #62005 (unexpected behavior when incrementally assigning to a member of a null object). (Laruence) + . Fixed bug #61998 (Using traits with method aliases appears to result in + crash during execution). (Dmitry) . Fixed bug #61978 (Object recursion not detected for classes that implement JsonSerializable). (Felipe) . Fixed bug #61991 (long overflow in realpath_cache_get()). (Anatoliy) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 602b600..b7e7cd3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3619,6 +3619,7 @@ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *tr } } ce->traits[ce->num_traits++] = trait; + trait->refcount++; } } /* }}} */ @@ -3870,8 +3871,8 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args, fn_copy = *fn; function_add_ref(&fn_copy); /* this function_name is never destroyed, because its refcount - greater than 1, classes are always destoyed in reverse order - and trait is declared early than this class */ + greater than 1 and classes are always destoyed before the + traits they use */ fn_copy.common.function_name = aliases[i]->alias; /* if it is 0, no modifieres has been changed */ diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 65fa851..19fd71e 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -215,6 +215,12 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) void _destroy_zend_class_traits_info(zend_class_entry *ce) { if (ce->num_traits > 0 && ce->traits) { + size_t i; + for (i = 0; i < ce->num_traits; i++) { + if (ce->traits[i]) { + destroy_zend_class(&ce->traits[i]); + } + } efree(ce->traits); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php