summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-11-09 09:16:45 +0000
committerDmitry Stogov <dmitry@php.net>2007-11-09 09:16:45 +0000
commit85a2d87bae285757f714ea31e78dfe39eb205fd9 (patch)
tree73537e214d3721b715b09a6f2e3962f6bafa77d2 /Zend
parenta91fe5ca49b724b34dc044f9bf7dea9109712ceb (diff)
downloadphp-git-85a2d87bae285757f714ea31e78dfe39eb205fd9.tar.gz
Fixed bug #43175 (__destruct() throwing an exception with __call() causes segfault)
Diffstat (limited to 'Zend')
-rwxr-xr-xZend/tests/bug43175.phpt24
-rw-r--r--Zend/zend_vm_def.h4
-rw-r--r--Zend/zend_vm_execute.h4
3 files changed, 28 insertions, 4 deletions
diff --git a/Zend/tests/bug43175.phpt b/Zend/tests/bug43175.phpt
new file mode 100755
index 0000000000..3bf6befc15
--- /dev/null
+++ b/Zend/tests/bug43175.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #43175 (__destruct() throwing an exception with __call() causes segfault)
+--FILE--
+<?php
+
+class foobar {
+ public function __destruct() {
+ throw new Exception();
+ }
+ public function __call($m, $a) {
+ return $this;
+ }
+}
+function foobar() {
+ return new foobar();
+}
+try {
+ foobar()->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 514c3f299e..c3919f166d 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 8ce7ef9724..8f8fdf3258 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)) {