From: Dmitry Stogov Date: Fri, 8 Apr 2011 10:02:07 +0000 (+0000) Subject: - Fixed bug #54358 (Closure, use and reference) X-Git-Tag: php-5.4.0alpha1~191^2~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=efcb9a71cdb3efde06dd3b347e64b21e4418c9db;p=php - Fixed bug #54358 (Closure, use and reference) - Fixed bug #54039 (use() of static variables in lambda functions can break staticness) --- 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 {