From: Xinchen Hui Date: Tue, 17 May 2016 12:27:16 +0000 (+0800) Subject: Revert "Fixed Bug #72213 (Finally leaks on nested exceptions)" X-Git-Tag: php-7.1.0alpha1~111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fad91468dbf48401ac3fc719dad3ce9f93e1a378;p=php Revert "Fixed Bug #72213 (Finally leaks on nested exceptions)" This reverts commit 5037ebf058bdc94e4426240a6d35fcf427d2eee2. --- diff --git a/Zend/tests/try/bug72213.phpt b/Zend/tests/try/bug72213.phpt deleted file mode 100644 index 624050295e..0000000000 --- a/Zend/tests/try/bug72213.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Bug #72213 (Finally leaks on nested exceptions) ---FILE-- -getMessage()); - var_dump($e->getPrevious()->getMessage()); -} -?> ---EXPECT-- -string(1) "b" -string(1) "a" diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index c4a97ab056..b2393c65b0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -7087,7 +7087,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) { uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes; int i; - uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0, prev_finally_op_end = 0; + uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0; int in_finally = 0; { @@ -7118,7 +7118,6 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) if (op_num >= EX(func)->op_array.try_catch_array[i].finally_op && op_num < EX(func)->op_array.try_catch_array[i].finally_end) { finally_op_end = EX(func)->op_array.try_catch_array[i].finally_end; - prev_finally_op_end = finally_op_end; in_finally = 1; } } @@ -7129,13 +7128,8 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var); cleanup_live_vars(execute_data, op_num, finally_op_num); - if (prev_finally_op_end) { - zval *prev_fast_call = EX_VAR(EX(func)->op_array.opcodes[prev_finally_op_end].op1.var); - - if (Z_OBJ_P(prev_fast_call)) { - zend_exception_set_previous(EG(exception), Z_OBJ_P(prev_fast_call)); - Z_OBJ_P(prev_fast_call) = NULL; - } + if (in_finally && Z_OBJ_P(fast_call)) { + zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call)); } Z_OBJ_P(fast_call) = EG(exception); EG(exception) = NULL; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index fc6f02a055..2301d48e07 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1694,7 +1694,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER( { uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes; int i; - uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0, prev_finally_op_end = 0; + uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0; int in_finally = 0; { @@ -1725,7 +1725,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER( if (op_num >= EX(func)->op_array.try_catch_array[i].finally_op && op_num < EX(func)->op_array.try_catch_array[i].finally_end) { finally_op_end = EX(func)->op_array.try_catch_array[i].finally_end; - prev_finally_op_end = finally_op_end; in_finally = 1; } } @@ -1736,13 +1735,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER( zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[finally_op_end].op1.var); cleanup_live_vars(execute_data, op_num, finally_op_num); - if (prev_finally_op_end) { - zval *prev_fast_call = EX_VAR(EX(func)->op_array.opcodes[prev_finally_op_end].op1.var); - - if (Z_OBJ_P(prev_fast_call)) { - zend_exception_set_previous(EG(exception), Z_OBJ_P(prev_fast_call)); - Z_OBJ_P(prev_fast_call) = NULL; - } + if (in_finally && Z_OBJ_P(fast_call)) { + zend_exception_set_previous(EG(exception), Z_OBJ_P(fast_call)); } Z_OBJ_P(fast_call) = EG(exception); EG(exception) = NULL;