diff --git a/Zend/tests/bug43175.phpt b/Zend/tests/bug43175.phpt new file mode 100755 index 00000000000..3bf6befc15b --- /dev/null +++ b/Zend/tests/bug43175.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #43175 (__destruct() throwing an exception with __call() causes segfault) +--FILE-- +unknown(); +} catch (Exception $e) { + echo "__call via traditional factory should be caught\n"; +} +?> +--EXPECT-- +__call via traditional factory should be caught diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index ddc059deb31..16e1e7cc925 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2167,6 +2167,9 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) } } + EX(function_state).function = (zend_function *) EX(op_array); + EG(function_state_ptr) = &EX(function_state); + if (EG(This)) { if (EG(exception) && IS_CTOR_CALL(EX(called_scope))) { if (IS_CTOR_USED(EX(called_scope))) { @@ -2190,8 +2193,6 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) EG(called_scope) = current_called_scope; } - EX(function_state).function = (zend_function *) EX(op_array); - EG(function_state_ptr) = &EX(function_state); zend_ptr_stack_clear_multiple(TSRMLS_C); if (EG(exception)) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 15edae4b4a5..cc22f5de17d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -283,6 +283,9 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) } } + EX(function_state).function = (zend_function *) EX(op_array); + EG(function_state_ptr) = &EX(function_state); + if (EG(This)) { if (EG(exception) && IS_CTOR_CALL(EX(called_scope))) { if (IS_CTOR_USED(EX(called_scope))) { @@ -306,8 +309,6 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) EG(called_scope) = current_called_scope; } - EX(function_state).function = (zend_function *) EX(op_array); - EG(function_state_ptr) = &EX(function_state); zend_ptr_stack_clear_multiple(TSRMLS_C); if (EG(exception)) {