1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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

Closes GH-15983.
This commit is contained in:
Niels Dossche
2024-09-22 12:00:51 +02:00
parent 05cb27a8f9
commit 27b3131422
3 changed files with 14 additions and 1 deletions

2
NEWS
View File

@@ -51,6 +51,8 @@ PHP NEWS
- Standard:
. Add support for backed enums in http_build_query(). (ilutov)
. Fixed bug GH-15982 (Assertion failure with array_find when references are
involved). (nielsdos)
- Zip:
. Added ZipArchive::ER_TRUNCATED_ZIP added in libzip 1.11. (Remi)

View File

@@ -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) {

View File

@@ -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"