mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.4'
* PHP-7.4: Fix leak when setting cyclic previous exception in finally
This commit is contained in:
commit
c5e8c9865e
2 changed files with 22 additions and 2 deletions
20
Zend/tests/exception_set_previous_leak.phpt
Normal file
20
Zend/tests/exception_set_previous_leak.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
Leak when setting recursive previous exception in finally handling
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
try {
|
||||
try {
|
||||
throw new Exception("Test");
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
} finally {
|
||||
throw $e;
|
||||
}
|
||||
} catch (Exception $e2) {
|
||||
echo $e2->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test
|
|
@ -81,11 +81,11 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
|
|||
zval pv, zv, rv;
|
||||
zend_class_entry *base_ce;
|
||||
|
||||
if (exception == add_previous || !add_previous || !exception) {
|
||||
if (!exception || !add_previous) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (zend_is_unwind_exit(add_previous)) {
|
||||
if (exception == add_previous || zend_is_unwind_exit(add_previous)) {
|
||||
OBJ_RELEASE(add_previous);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue