Skip to content

Commit 97a8483

Browse files
committed
Fixed bug #76383 (array_map on $GLOBALS returns IS_INDIRECT)
1 parent 34fb429 commit 97a8483

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818
- Standard:
1919
. Fixed bug #76335 ("link(): Bad file descriptor" with non-ASCII path).
2020
(Anatol)
21+
. Fixed bug #76383 (array_map on $GLOBALS returns IS_INDIRECT). (Bob)
2122

2223
24 May 2018, PHP 7.1.18
2324

Zend/tests/bug76383.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #76383: array_map on $GLOBALS returns IS_INDIRECT
3+
--FILE--
4+
<?php
5+
6+
$a = 1;
7+
array_map(function($x) use (&$lastval) { $lastval = $x; }, $GLOBALS);
8+
var_dump(gettype($lastval), $lastval); // will contain $a
9+
10+
?>
11+
--EXPECT--
12+
string(7) "integer"
13+
int(1)

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5348,7 +5348,7 @@ PHP_FUNCTION(array_map)
53485348

53495349
array_init_size(return_value, maxlen);
53505350

5351-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
5351+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
53525352
fci.retval = &result;
53535353
fci.param_count = 1;
53545354
fci.params = &arg;

0 commit comments

Comments
 (0)