Skip to content

Commit fd81e70

Browse files
committed
Fixed incorrect behavior of observer API.
ZEND_HANDLE_EXCEPTION might call zend_observer_fcall_end() even if exception is cought by function. The fix moved zend_observer_fcall_end() into a right place and remove OBSERVER sepecialization for ZEND_HANDLE_EXCEPTION handler.
1 parent edf0c6a commit fd81e70

File tree

3 files changed

+689
-746
lines changed

3 files changed

+689
-746
lines changed

Zend/zend_vm_def.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7688,6 +7688,9 @@ ZEND_VM_HELPER(zend_dispatch_try_catch_finally_helper, ANY, ANY, uint32_t try_ca
76887688
}
76897689

76907690
/* Uncaught exception */
7691+
if (zend_observer_fcall_op_array_extension != -1) {
7692+
zend_observer_fcall_end(execute_data, EX(return_value));
7693+
}
76917694
cleanup_live_vars(execute_data, op_num, 0);
76927695
if (UNEXPECTED((EX_CALL_INFO() & ZEND_CALL_GENERATOR) != 0)) {
76937696
zend_generator *generator = zend_get_running_generator(EXECUTE_DATA_C);
@@ -7702,7 +7705,7 @@ ZEND_VM_HELPER(zend_dispatch_try_catch_finally_helper, ANY, ANY, uint32_t try_ca
77027705
}
77037706
}
77047707

7705-
ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY, SPEC(OBSERVER))
7708+
ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
77067709
{
77077710
const zend_op *throw_op = EG(opline_before_exception);
77087711
uint32_t throw_op_num = throw_op - EX(func)->op_array.opcodes;
@@ -7731,7 +7734,6 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY, SPEC(OBSERVER))
77317734
}
77327735
}
77337736

7734-
ZEND_OBSERVER_FCALL_END(execute_data, EX(return_value));
77357737
cleanup_unfinished_calls(execute_data, throw_op_num);
77367738

77377739
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {

0 commit comments

Comments
 (0)