]> granicus.if.org Git - php/commitdiff
Fixed bug #43175 (__destruct() throwing an exception with __call() causes segfault)
authorDmitry Stogov <dmitry@php.net>
Tue, 6 Nov 2007 14:56:14 +0000 (14:56 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 6 Nov 2007 14:56:14 +0000 (14:56 +0000)
Zend/tests/bug43175.phpt [new file with mode: 0755]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/Zend/tests/bug43175.phpt b/Zend/tests/bug43175.phpt
new file mode 100755 (executable)
index 0000000..3bf6bef
--- /dev/null
@@ -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
index 207a241a5ac0d9c5ad09839c515960c9c746a574..42f550430ebcb757828253e341741d4e7d00f38b 100644 (file)
@@ -2092,6 +2092,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))) {
@@ -2115,8 +2118,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)) {
index ab6b84ae51b607ec7cf33b8212133b80c851ce74..d4782320b3fb7cf387810dc651c162ec7a56bf59 100644 (file)
@@ -275,6 +275,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))) {
@@ -298,8 +301,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)) {