mirror of
https://github.com/php/php-src.git
synced 2024-12-03 23:05:57 +08:00
05bd1423ee
There are more places in zend_hash.c where the resize happened after some values on the HashTable struct were set. I reordered them all, but writing a test for these would rely on the particular amount of bytes allocated at given points in time.
30 lines
582 B
PHP
30 lines
582 B
PHP
--TEST--
|
|
GH-11189: Exceeding memory limit in zend_hash_do_resize leaves the array in an invalid state (packed array)
|
|
--SKIPIF--
|
|
<?php
|
|
if (getenv("USE_ZEND_ALLOC") === "0") die("skip ZMM is disabled");
|
|
?>
|
|
--INI--
|
|
memory_limit=2M
|
|
--FILE--
|
|
<?php
|
|
|
|
ob_start(function() {
|
|
global $a;
|
|
for ($i = count($a); $i > 0; --$i) {
|
|
$a[] = 2;
|
|
}
|
|
fwrite(STDOUT, "Success");
|
|
});
|
|
|
|
$a = [];
|
|
// trigger OOM in a resize operation
|
|
while (1) {
|
|
$a[] = 1;
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Success
|
|
Fatal error: Allowed memory size of %s bytes exhausted%s(tried to allocate %s bytes) in %s on line %d
|