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:
2
NEWS
2
NEWS
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
11
ext/standard/tests/array/gh15982.phpt
Normal file
11
ext/standard/tests/array/gh15982.phpt
Normal 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"
|
||||
Reference in New Issue
Block a user