Skip to content

Commit 27b3131

Browse files
committed
Fix GH-15982: Assertion failure with array_find when references are involved
Closes GH-15983.
1 parent 05cb27a commit 27b3131

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ PHP NEWS
5151

5252
- Standard:
5353
. Add support for backed enums in http_build_query(). (ilutov)
54+
. Fixed bug GH-15982 (Assertion failure with array_find when references are
55+
involved). (nielsdos)
5456

5557
- Zip:
5658
. Added ZipArchive::ER_TRUNCATED_ZIP added in libzip 1.11. (Remi)

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6628,7 +6628,7 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z
66286628

66296629
if (retval_true) {
66306630
if (result_value != NULL) {
6631-
ZVAL_COPY(result_value, &args[0]);
6631+
ZVAL_COPY_DEREF(result_value, &args[0]);
66326632
}
66336633

66346634
if (result_key != NULL) {

ext/standard/tests/array/gh15982.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-15982 (Assertion failure with array_find when references are involved)
3+
--FILE--
4+
<?php
5+
$var = "hello";
6+
$arrayWithRef = [];
7+
$arrayWithRef[0] =& $var;
8+
var_dump(array_find($arrayWithRef, fn () => true));
9+
?>
10+
--EXPECT--
11+
string(5) "hello"

0 commit comments

Comments
 (0)