Skip to content

Commit 30aa2e8

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78840: imploding $GLOBALS crashes
2 parents 717730d + fee3863 commit 30aa2e8

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PHP NEWS
2525

2626
- Standard:
2727
. Fixed bug #77638 (var_export'ing certain class instances segfaults). (cmb)
28+
. Fixed bug #78840 (imploding $GLOBALS crashes). (cmb)
2829

2930
28 Nov 2019, PHP 7.4.0
3031

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,14 +1199,14 @@ PHPAPI void php_implode(const zend_string *glue, zval *pieces, zval *return_valu
11991199
RETURN_EMPTY_STRING();
12001200
} else if (numelems == 1) {
12011201
/* loop to search the first not undefined element... */
1202-
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pieces), tmp) {
1202+
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(pieces), tmp) {
12031203
RETURN_STR(zval_get_string(tmp));
12041204
} ZEND_HASH_FOREACH_END();
12051205
}
12061206

12071207
ptr = strings = do_alloca((sizeof(*strings)) * numelems, use_heap);
12081208

1209-
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pieces), tmp) {
1209+
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(pieces), tmp) {
12101210
if (EXPECTED(Z_TYPE_P(tmp) == IS_STRING)) {
12111211
ptr->str = Z_STR_P(tmp);
12121212
len += ZSTR_LEN(ptr->str);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #78840 (imploding $GLOBALS crashes)
3+
--FILE--
4+
<?php
5+
$glue = '';
6+
@implode($glue, $GLOBALS);
7+
echo "done\n";
8+
?>
9+
--EXPECT--
10+
done

0 commit comments

Comments
 (0)