Skip to content

Fix GH-15982: Assertion failure with array_find when references are involved #15983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -6628,7 +6628,7 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z

if (retval_true) {
if (result_value != NULL) {
ZVAL_COPY(result_value, &args[0]);
ZVAL_COPY_DEREF(result_value, &args[0]);
}

if (result_key != NULL) {
Expand Down
11 changes: 11 additions & 0 deletions ext/standard/tests/array/gh15982.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
GH-15982 (Assertion failure with array_find when references are involved)
--FILE--
<?php
$var = "hello";
$arrayWithRef = [];
$arrayWithRef[0] =& $var;
var_dump(array_find($arrayWithRef, fn () => true));
?>
--EXPECT--
string(5) "hello"
Loading