From efcb9a71cdb3efde06dd3b347e64b21e4418c9db Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 8 Apr 2011 10:02:07 +0000 Subject: [PATCH] - Fixed bug #54358 (Closure, use and reference) - Fixed bug #54039 (use() of static variables in lambda functions can break staticness) --- Zend/tests/bug54039.phpt | 58 ++++++++++++++++++++++++++++++++++++++++ Zend/tests/bug54358.phpt | 39 +++++++++++++++++++++++++++ Zend/zend_variables.c | 1 + 3 files changed, 98 insertions(+) create mode 100644 Zend/tests/bug54039.phpt create mode 100644 Zend/tests/bug54358.phpt diff --git a/Zend/tests/bug54039.phpt b/Zend/tests/bug54039.phpt new file mode 100644 index 0000000000..ccdfe94305 --- /dev/null +++ b/Zend/tests/bug54039.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bug #54039 (use() of static variables in lambda functions can break staticness) +--FILE-- +call($function = 'md5'); +}; + +$closure(); + +var_dump($function); + +$closure = function() use ($asserter, $function) { + $asserter->call($function); +}; + +$closure(); + +var_dump($function); + +$closure = function() use ($asserter, $function) { + $asserter->call($function); +}; + +$closure(); + +var_dump($function); +?> +--EXPECT-- +string(3) "md5" +string(3) "md5" +string(3) "md5" diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 77d42bc5c4..5e500ea635 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -216,6 +216,7 @@ ZEND_API int zval_copy_static_var(zval **p TSRMLS_DC, int num_args, va_list args } else if (Z_ISREF_PP(p)) { ALLOC_INIT_ZVAL(tmp); ZVAL_COPY_VALUE(tmp, *p); + zval_copy_ctor(tmp); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); } else { -- 2.50.1