]> granicus.if.org Git - php/commitdiff
Fixed bug #76383 (array_map on $GLOBALS returns IS_INDIRECT)
authorBob Weinand <bobwei9@hotmail.com>
Sun, 27 May 2018 22:48:35 +0000 (00:48 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Sun, 27 May 2018 22:48:35 +0000 (00:48 +0200)
NEWS
Zend/tests/bug76383.phpt [new file with mode: 0644]
ext/standard/array.c

diff --git a/NEWS b/NEWS
index 695f69346a201395d309f3feb02787a1604fd220..339353dc5e735476a57419fd5eb6820b95abda70 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PHP                                                                        NEWS
 - Standard:
   . Fixed bug #76335 ("link(): Bad file descriptor" with non-ASCII path).
     (Anatol)
+  . Fixed bug #76383 (array_map on $GLOBALS returns IS_INDIRECT). (Bob)
 
 24 May 2018, PHP 7.1.18
 
diff --git a/Zend/tests/bug76383.phpt b/Zend/tests/bug76383.phpt
new file mode 100644 (file)
index 0000000..ae26ba8
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #76383: array_map on $GLOBALS returns IS_INDIRECT
+--FILE--
+<?php
+
+$a = 1;
+array_map(function($x) use (&$lastval) { $lastval = $x; }, $GLOBALS);
+var_dump(gettype($lastval), $lastval); // will contain $a
+
+?>
+--EXPECT--
+string(7) "integer"
+int(1)
index 970735cf47c6702ceda32cb2c43b187405d8a9a2..5905ae49298df6161dd947c928b530c678c18e9e 100644 (file)
@@ -5348,7 +5348,7 @@ PHP_FUNCTION(array_map)
 
                array_init_size(return_value, maxlen);
 
-               ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
+               ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
                        fci.retval = &result;
                        fci.param_count = 1;
                        fci.params = &arg;