mirror of
https://github.com/php/php-src.git
synced 2026-04-22 07:28:09 +02:00
Merge branch 'PHP-7.3'
* PHP-7.3: Fix #76778: array_reduce leaks memory if callback throws exception
This commit is contained in:
@@ -5994,6 +5994,7 @@ PHP_FUNCTION(array_reduce)
|
||||
} else {
|
||||
zval_ptr_dtor(&args[1]);
|
||||
zval_ptr_dtor(&args[0]);
|
||||
zval_ptr_dtor(&result);
|
||||
return;
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #76778 (array_reduce leaks memory if callback throws exception)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
|
||||
?>
|
||||
--INI--
|
||||
memory_limit=32M
|
||||
--FILE--
|
||||
<?php
|
||||
for ($i = 0; $i < 100; $i++) {
|
||||
try {
|
||||
array_reduce(
|
||||
[1],
|
||||
function ($carry, $item) {
|
||||
throw new Exception;
|
||||
},
|
||||
range(1, 200000)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
===DONE===
|
||||
Reference in New Issue
Block a user