diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-06-14 16:02:21 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-06-14 16:02:21 +0200 |
commit | f0f8d7084aec4be5c07f02f2e29c2820f85c8315 (patch) | |
tree | 02e9b39d5b0088a0e27126010c96a748d824d055 /Zend | |
parent | 90ceaa9e92fadfef4c21ec0f76063c4387beb561 (diff) | |
download | php-f0f8d7084aec4be5c07f02f2e29c2820f85c8315.tar.gz |
Imported Upstream version 5.4.4upstream/5.4.4
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/traits/bug61998.phpt | 68 | ||||
-rw-r--r-- | Zend/zend_compile.c | 19 | ||||
-rw-r--r-- | Zend/zend_multibyte.c | 2 | ||||
-rw-r--r-- | Zend/zend_opcode.c | 6 |
4 files changed, 10 insertions, 85 deletions
diff --git a/Zend/tests/traits/bug61998.phpt b/Zend/tests/traits/bug61998.phpt deleted file mode 100644 index 612caa066..000000000 --- a/Zend/tests/traits/bug61998.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Bug #61998 (Using traits with method aliases appears to result in crash during execution) ---FILE-- -<?php -class Foo { - use T1 { - func as newFunc; - } - - public function func() { - echo "From Foo\n"; - } -} - -trait T1 { - public function func() { - echo "From T1\n"; - } -} - -class Bar { - public function func() { - echo "From Bar\n"; - } - public function func2() { - echo "From Bar\n"; - } - public function func3() { - echo "From Bar\n"; - } - use T1 { - func as newFunc; - func as func2; - } - use T2 { - func2 as newFunc2; - func2 as newFunc3; - func2 as func3; - } -} - -trait T2 { - public function func2() { - echo "From T2\n"; - } -} - -$f = new Foo(); - -$f->newFunc(); //from T1 -$f->func(); //from Foo - -$b = new Bar(); -$b->newFunc(); //from T1 -$b->func(); //from Bar -$b->func2(); //from Bar -$b->newFunc2(); //from T2 -$b->newFunc3(); //from T2 -$b->func3(); //from Bar ---EXPECTF-- -From T1 -From Foo -From T1 -From Bar -From Bar -From T2 -From T2 -From Bar diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 28f98249d..602b60041 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3619,7 +3619,6 @@ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *tr } } ce->traits[ce->num_traits++] = trait; - trait->refcount++; } } /* }}} */ @@ -3871,8 +3870,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 and classes are always destoyed before the - traits they use */ + greater than 1, classes are always destoyed in reverse order + and trait is declared early than this class */ fn_copy.common.function_name = aliases[i]->alias; /* if it is 0, no modifieres has been changed */ @@ -4077,14 +4076,14 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ size_t i; /* prepare copies of trait function tables for combination */ - function_tables = emalloc(sizeof(HashTable*) * ce->num_traits); - resulting_table = (HashTable *)emalloc(sizeof(HashTable)); + function_tables = malloc(sizeof(HashTable*) * ce->num_traits); + resulting_table = (HashTable *) malloc(sizeof(HashTable)); /* TODO: revisit this start size, may be its not optimal */ - zend_hash_init_ex(resulting_table, 10, NULL, NULL, 0, 0); + zend_hash_init_ex(resulting_table, 10, NULL, NULL, 1, 0); for (i = 0; i < ce->num_traits; i++) { - function_tables[i] = (HashTable *)emalloc(sizeof(HashTable)); + function_tables[i] = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init_ex(function_tables[i], ce->traits[i]->function_table.nNumOfElements, NULL, NULL, 1, 0); if (ce->trait_precedences) { @@ -4117,14 +4116,14 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ for (i = 0; i < ce->num_traits; i++) { /* zend_hash_destroy(function_tables[i]); */ zend_hash_graceful_destroy(function_tables[i]); - efree(function_tables[i]); + free(function_tables[i]); } - efree(function_tables); + free(function_tables); /* free temporary resulting table */ /* zend_hash_destroy(resulting_table); */ zend_hash_graceful_destroy(resulting_table); - efree(resulting_table); + free(resulting_table); } /* }}} */ diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index 379f50b01..9149fdcf0 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -168,7 +168,7 @@ ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(TSRMLS_D) ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size TSRMLS_DC) { if (CG(script_encoding_list)) { - free(CG(script_encoding_list)); + efree(CG(script_encoding_list)); } CG(script_encoding_list) = encoding_list; CG(script_encoding_list_size) = encoding_list_size; diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 19fd71e76..65fa85185 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -215,12 +215,6 @@ 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); } |