mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-5.5' into PHP-5.6
This commit is contained in:
commit
168be6f250
4 changed files with 42 additions and 6 deletions
16
Zend/tests/bug69174.phpt
Normal file
16
Zend/tests/bug69174.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--TEST--
|
||||
Bug #69174 (leaks when unused inner class use traits precedence)
|
||||
--FILE--
|
||||
<?php
|
||||
function test() {
|
||||
class C1 {
|
||||
use T1, T2 {
|
||||
T1::foo insteadof T2;
|
||||
T1::bar insteadof T2;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
==DONE==
|
|
@ -4343,16 +4343,20 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
|
|||
for (i = 0; i < ce->num_traits; i++) {
|
||||
if (ce->trait_precedences) {
|
||||
HashTable exclude_table;
|
||||
zend_trait_precedence **precedences;
|
||||
|
||||
/* TODO: revisit this start size, may be its not optimal */
|
||||
zend_hash_init_ex(&exclude_table, 2, NULL, NULL, 0, 0);
|
||||
|
||||
zend_traits_compile_exclude_table(&exclude_table, ce->trait_precedences, ce->traits[i]);
|
||||
precedences = ce->trait_precedences;
|
||||
ce->trait_precedences = NULL;
|
||||
zend_traits_compile_exclude_table(&exclude_table, precedences, ce->traits[i]);
|
||||
|
||||
/* copies functions, applies defined aliasing, and excludes unused trait methods */
|
||||
zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, &exclude_table);
|
||||
|
||||
zend_hash_destroy(&exclude_table);
|
||||
ce->trait_precedences = precedences;
|
||||
} else {
|
||||
zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, NULL);
|
||||
}
|
||||
|
@ -4360,6 +4364,17 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
|
|||
|
||||
zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t)zend_fixup_trait_method, ce TSRMLS_CC);
|
||||
|
||||
if (ce->trait_precedences) {
|
||||
i = 0;
|
||||
while (ce->trait_precedences[i]) {
|
||||
if (ce->trait_precedences[i]->exclude_from_classes) {
|
||||
efree(ce->trait_precedences[i]->exclude_from_classes);
|
||||
ce->trait_precedences[i]->exclude_from_classes = NULL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (overriden) {
|
||||
zend_hash_destroy(overriden);
|
||||
FREE_HASHTABLE(overriden);
|
||||
|
|
|
@ -256,9 +256,14 @@ void _destroy_zend_class_traits_info(zend_class_entry *ce)
|
|||
efree(ce->trait_precedences[i]->trait_method);
|
||||
|
||||
if (ce->trait_precedences[i]->exclude_from_classes) {
|
||||
zend_uint j = 0;
|
||||
zend_trait_precedence *cur_precedence = ce->trait_precedences[i];
|
||||
while (cur_precedence->exclude_from_classes[j]) {
|
||||
efree(cur_precedence->exclude_from_classes[j]);
|
||||
j++;
|
||||
}
|
||||
efree(ce->trait_precedences[i]->exclude_from_classes);
|
||||
}
|
||||
|
||||
efree(ce->trait_precedences[i]);
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
|
|||
|
||||
if (SIGG(active)) {
|
||||
if (SIGG(depth) == 0) { /* try to handle signal */
|
||||
if (SIGG(blocked) != -1) { /* inverse */
|
||||
SIGG(blocked) = -1; /* signal is not blocked */
|
||||
if (SIGG(blocked) != 0) { /* inverse */
|
||||
SIGG(blocked) = 0; /* signal is not blocked */
|
||||
}
|
||||
if (SIGG(running) == 0) {
|
||||
SIGG(running) = 1;
|
||||
|
@ -99,7 +99,7 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
|
|||
SIGG(running) = 0;
|
||||
}
|
||||
} else { /* delay signal handling */
|
||||
SIGG(blocked) = 0; /* signal is blocked */
|
||||
SIGG(blocked) = 1; /* signal is blocked */
|
||||
|
||||
if ((queue = SIGG(pavail))) { /* if none available it's simply forgotton */
|
||||
SIGG(pavail) = queue->next;
|
||||
|
@ -314,7 +314,7 @@ void zend_signal_deactivate(TSRMLS_D)
|
|||
SIGNAL_BEGIN_CRITICAL();
|
||||
SIGG(active) = 0;
|
||||
SIGG(running) = 0;
|
||||
SIGG(blocked) = -1;
|
||||
SIGG(blocked) = 0;
|
||||
SIGG(depth) = 0;
|
||||
SIGNAL_END_CRITICAL();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue