From 2e925f6f19c3220e9f3d8dc68377e47209532196 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 3 Oct 2011 17:01:17 +0000 Subject: [PATCH] Fixed bug #55825, and add test script --- NEWS | 2 ++ Zend/tests/bug55825.phpt | 17 +++++++++++++++++ Zend/zend_compile.c | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/bug55825.phpt diff --git a/NEWS b/NEWS index 39efbee170..456e2335b0 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ PHP NEWS (Felipe, Laruence) . Fixed bug #55758 (Digest Authenticate missed in 5.4) . (Laruence) . Fixed bug #55622 (memory corruption in parse_ini_string). (Pierre) + . Fixed bug #55825 (Missing initial value of static locals in trait methods). + (Laruence) - Zlib: . Fixed bug #55544 (ob_gzhandler always conflicts with diff --git a/Zend/tests/bug55825.phpt b/Zend/tests/bug55825.phpt new file mode 100644 index 0000000000..23fc933ee6 --- /dev/null +++ b/Zend/tests/bug55825.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #55825 (Missing initial value of static locals in trait methods) +--FILE-- +inc(); +$c1->inc(); +--EXPECT-- +1 +2 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 83de4ea60d..45c8e6c68d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3695,7 +3695,7 @@ static void zend_traits_duplicate_function(zend_function *fe, zend_class_entry * ALLOC_HASHTABLE(tmpHash); zend_hash_init(tmpHash, zend_hash_num_elements(fe->op_array.static_variables), NULL, ZVAL_PTR_DTOR, 0); - zend_hash_apply_with_arguments(tmpHash TSRMLS_CC, (apply_func_args_t)zval_copy_static_var, 1, fe->op_array.static_variables); + zend_hash_apply_with_arguments(fe->op_array.static_variables TSRMLS_CC, (apply_func_args_t)zval_copy_static_var, 1, tmpHash); fe->op_array.static_variables = tmpHash; } @@ -4101,6 +4101,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ zend_hash_graceful_destroy(resulting_table); free(resulting_table); } +/* }}} */ static zend_class_entry* find_first_definition(zend_class_entry *ce, size_t current_trait, const char* prop_name, int prop_name_length, ulong prop_hash, zend_class_entry *coliding_ce) /* {{{ */ { -- 2.40.0