Skip to content

Commit fa2c519

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-9697: array_walk($ffiInstance, function () {}) crashes due to expecting mutable array
2 parents 296a095 + d9651a9 commit fa2c519

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/ffi/tests/gh9697.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-9697 (array_walk($ffiInstance, function () {}) crashes due to expecting mutable array)
3+
--EXTENSIONS--
4+
ffi
5+
--INI--
6+
ffi.enable=1
7+
--FILE--
8+
<?php
9+
$x = FFI::new('int');
10+
array_walk($x, function($x) { echo "test\n"; });
11+
?>
12+
DONE
13+
--EXPECT--
14+
DONE

ext/standard/array.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,10 @@ static int php_array_walk(
13191319
* levels of recursion. */
13201320
zend_fcall_info fci = context->fci;
13211321

1322+
if (zend_hash_num_elements(target_hash) == 0) {
1323+
return result;
1324+
}
1325+
13221326
/* Set up known arguments */
13231327
ZVAL_UNDEF(&args[1]);
13241328
if (userdata) {

0 commit comments

Comments
 (0)