diff --git a/NEWS b/NEWS index f1f30713a63..769831bf86c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2008, PHP 5.2.6 +- Fixed bug #43175 (__destruct() throwing an exception with __call() causes + segfault). (Dmitry) 08 Nov 2007, PHP 5.2.5 - Upgraded PCRE to version 7.3 (Nuno) 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 514c3f299e1..c3919f166d0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1995,6 +1995,8 @@ 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); ctor_opline = (zend_op*)zend_ptr_stack_pop(&EG(arg_types_stack)); if (EG(This)) { @@ -2017,8 +2019,6 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) } zend_ptr_stack_2_pop(&EG(arg_types_stack), (void**)&EX(object), (void**)&EX(fbc)); - 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 8ce7ef97248..8f8fdf3258b 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -280,6 +280,8 @@ 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); ctor_opline = (zend_op*)zend_ptr_stack_pop(&EG(arg_types_stack)); if (EG(This)) { @@ -302,8 +304,6 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) } zend_ptr_stack_2_pop(&EG(arg_types_stack), (void**)&EX(object), (void**)&EX(fbc)); - 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)) {