xref: /php-src/Zend/tests/gh12073.phpt (revision af2110e6)
1--TEST--
2GH-12073: Freeing of non-ZMM pointer of incompletely allocated closure
3--SKIPIF--
4<?php
5if (getenv("USE_ZEND_ALLOC") === "0" && getenv("USE_TRACKED_ALLOC") !== "1") {
6    die("skip Zend MM disabled");
7}
8?>
9--FILE--
10<?php
11
12function test() {
13	$k = 1;
14	return function () use ($k) {
15		foo();
16	};
17}
18
19ini_set('memory_limit', '2M');
20
21$array = [];
22for ($i = 0; $i < 10_000; $i++) {
23	$array[] = test();
24}
25
26?>
27--EXPECTF--
28Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
29