mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #76778: array_reduce leaks memory if callback throws exception
This commit is contained in:
commit
1de17428f6
2
NEWS
2
NEWS
@ -25,6 +25,8 @@ PHP NEWS
|
|||||||
Siebels)
|
Siebels)
|
||||||
|
|
||||||
- Standard:
|
- Standard:
|
||||||
|
. Fixed bug #76778 (array_reduce leaks memory if callback throws exception).
|
||||||
|
(cmb)
|
||||||
. Fixed bug #76755 (setcookie does not accept "double" type for expire time).
|
. Fixed bug #76755 (setcookie does not accept "double" type for expire time).
|
||||||
(Laruence)
|
(Laruence)
|
||||||
. Fixed bug #76674 (improve array_* failure messages exposing what was passed
|
. Fixed bug #76674 (improve array_* failure messages exposing what was passed
|
||||||
|
@ -5994,6 +5994,7 @@ PHP_FUNCTION(array_reduce)
|
|||||||
} else {
|
} else {
|
||||||
zval_ptr_dtor(&args[1]);
|
zval_ptr_dtor(&args[1]);
|
||||||
zval_ptr_dtor(&args[0]);
|
zval_ptr_dtor(&args[0]);
|
||||||
|
zval_ptr_dtor(&result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
26
ext/standard/tests/array/bug76778.phpt
Normal file
26
ext/standard/tests/array/bug76778.phpt
Normal file
@ -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===
|
Loading…
Reference in New Issue
Block a user