From: Dmitry Stogov Date: Wed, 10 Aug 2005 08:22:01 +0000 (+0000) Subject: Fixed bug #33940 (array_map() fails to pass by reference when called recursively) X-Git-Tag: php-5.1.0RC1~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54931f525908c3f56ec7a08b6f6cc5ad2fd62518;p=php Fixed bug #33940 (array_map() fails to pass by reference when called recursively) --- diff --git a/NEWS b/NEWS index f88238a429..300e913aab 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ PHP NEWS (Jani) - Fixed bug #33958 (duplicate cookies and magic_quotes=off may cause a crash). (Ilia) +- Fixed bug #33940 (array_map() fails to pass by reference when called + recursively). (Dmitry) - Fixed bug #33917 (number_format() output with > 1 char separators). (Jani) - Fixed bug #33904 (input array keys being escaped when magic quotes is off). (Ilia) diff --git a/ext/standard/array.c b/ext/standard/array.c index 67598e8d66..e34c915e2f 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4252,6 +4252,7 @@ PHP_FUNCTION(array_map) efree(array_pos); return; } + SEPARATE_ZVAL_IF_NOT_REF(pargs[i]); args[i] = *pargs[i]; array_len[i] = zend_hash_num_elements(Z_ARRVAL_PP(pargs[i])); if (array_len[i] > maxlen) { diff --git a/ext/standard/tests/array/bug33940.phpt b/ext/standard/tests/array/bug33940.phpt new file mode 100755 index 0000000000..f5727297c6 --- /dev/null +++ b/ext/standard/tests/array/bug33940.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #33940 array_map() fails to pass by reference when called recursively +--INI-- +error_reporting=4095 +--FILE-- + +--EXPECT-- +Array: Array +( + [0] => Array + ( + [0] => 0 + ) + + [1] => 0 +) +Return: Array +( + [0] => Array + ( + [0] => 2 + ) + + [1] => 2 +) +Array: Array +( + [0] => Array + ( + [0] => 1 + ) + + [1] => 1 +) +Return: Array +( + [0] => Array + ( + [0] => 2 + ) + + [1] => 2 +)