Skip to content

Commit fad9146

Browse files
committed
Revert "Fixed Bug #72213 (Finally leaks on nested exceptions)"
This reverts commit 5037ebf.
1 parent 0c8879e commit fad9146

File tree

3 files changed

+6
-43
lines changed

3 files changed

+6
-43
lines changed

Zend/tests/try/bug72213.phpt

Lines changed: 0 additions & 25 deletions
This file was deleted.

Zend/zend_vm_def.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7087,7 +7087,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
70877087
{
70887088
uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
70897089
int i;
7090-
uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0, prev_finally_op_end = 0;
7090+
uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
70917091
int in_finally = 0;
70927092

70937093
{
@@ -7118,7 +7118,6 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
71187118
if (op_num >= EX(func)->op_array.try_catch_array[i].finally_op &&
71197119
op_num < EX(func)->op_array.try_catch_array[i].finally_end) {
71207120
finally_op_end = EX(func)->op_array.try_catch_array[i].finally_end;
7121-
prev_finally_op_end = finally_op_end;
71227121
in_finally = 1;
71237122
}
71247123
}
@@ -7129,13 +7128,8 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
71297128
zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var);
71307129

71317130
cleanup_live_vars(execute_data, op_num, finally_op_num);
7132-
if (prev_finally_op_end) {
7133-
zval *prev_fast_call = EX_VAR(EX(func)->op_array.opcodes[prev_finally_op_end].op1.var);
7134-
7135-
if (Z_OBJ_P(prev_fast_call)) {
7136-
zend_exception_set_previous(EG(exception), Z_OBJ_P(prev_fast_call));
7137-
Z_OBJ_P(prev_fast_call) = NULL;
7138-
}
7131+
if (in_finally && Z_OBJ_P(fast_call)) {
7132+
zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call));
71397133
}
71407134
Z_OBJ_P(fast_call) = EG(exception);
71417135
EG(exception) = NULL;

Zend/zend_vm_execute.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(
16941694
{
16951695
uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
16961696
int i;
1697-
uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0, prev_finally_op_end = 0;
1697+
uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
16981698
int in_finally = 0;
16991699

17001700
{
@@ -1725,7 +1725,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(
17251725
if (op_num >= EX(func)->op_array.try_catch_array[i].finally_op &&
17261726
op_num < EX(func)->op_array.try_catch_array[i].finally_end) {
17271727
finally_op_end = EX(func)->op_array.try_catch_array[i].finally_end;
1728-
prev_finally_op_end = finally_op_end;
17291728
in_finally = 1;
17301729
}
17311730
}
@@ -1736,13 +1735,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(
17361735
zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var);
17371736

17381737
cleanup_live_vars(execute_data, op_num, finally_op_num);
1739-
if (prev_finally_op_end) {
1740-
zval *prev_fast_call = EX_VAR(EX(func)->op_array.opcodes[prev_finally_op_end].op1.var);
1741-
1742-
if (Z_OBJ_P(prev_fast_call)) {
1743-
zend_exception_set_previous(EG(exception), Z_OBJ_P(prev_fast_call));
1744-
Z_OBJ_P(prev_fast_call) = NULL;
1745-
}
1738+
if (in_finally && Z_OBJ_P(fast_call)) {
1739+
zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call));
17461740
}
17471741
Z_OBJ_P(fast_call) = EG(exception);
17481742
EG(exception) = NULL;

0 commit comments

Comments
 (0)