1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 08:28:26 +02:00
Files
Niels Dossche 75cca9f19e Fix memory leaks in array_any() / array_all()
The return value is overwritten, but if the key was not an interned
string we should destroy it.

Closes GH-17977.
2025-03-05 19:52:16 +01:00

19 lines
411 B
PHP

--TEST--
array_any() / array_all() leak
--DESCRIPTION--
Found in GH-16831#issuecomment-2700410631
--FILE--
<?php
// Don't touch this str_repeat + random_int combination,
// this is to circumvent SCCP and interning
$key = str_repeat('abc', random_int(3, 3));
var_dump(array_any([$key => 1], static fn () => true));
var_dump(array_all([$key => 1], static fn () => false));
?>
--EXPECT--
bool(true)
bool(false)