mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
af2110e664
Addref to relevant fields before allocating any memory. Also only set/remove the ZEND_ACC_HEAP_RT_CACHE flag after allocating memory. Fixes GH-12073 Closes GH-12074
29 lines
524 B
PHP
29 lines
524 B
PHP
--TEST--
|
|
GH-12073: Freeing of non-ZMM pointer of incompletely allocated closure
|
|
--SKIPIF--
|
|
<?php
|
|
if (getenv("USE_ZEND_ALLOC") === "0" && getenv("USE_TRACKED_ALLOC") !== "1") {
|
|
die("skip Zend MM disabled");
|
|
}
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
function test() {
|
|
$k = 1;
|
|
return function () use ($k) {
|
|
foo();
|
|
};
|
|
}
|
|
|
|
ini_set('memory_limit', '2M');
|
|
|
|
$array = [];
|
|
for ($i = 0; $i < 10_000; $i++) {
|
|
$array[] = test();
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
|