Skip to content

Commit

Permalink
Fixed bug #61998 (Using traits with method aliases appears to result …
Browse files Browse the repository at this point in the history
…in crash during execution)
dstogov committed May 21, 2012
2 parents 7632a32 + 2ae8d2f commit 90e2310
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
@@ -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 */
6 changes: 6 additions & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 90e2310

Please sign in to comment.