]> granicus.if.org Git - php/commitdiff
Fixed bug #47714 (autoloading classes inside exception_handler leads to crashes)
authorDmitry Stogov <dmitry@php.net>
Thu, 26 Mar 2009 10:56:25 +0000 (10:56 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 26 Mar 2009 10:56:25 +0000 (10:56 +0000)
Zend/tests/bug47714.phpt [new file with mode: 0644]
Zend/zend.c

diff --git a/Zend/tests/bug47714.phpt b/Zend/tests/bug47714.phpt
new file mode 100644 (file)
index 0000000..c784f8f
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+--FILE--
+<?php
+function au($class) {
+        eval('class handler {
+                  function handle($e) {
+                      echo $e->getMessage()."\n";
+                  }
+              }');
+}
+
+function __autoload($class) {
+        au($class);
+}
+
+//spl_autoload_register('au');
+
+set_exception_handler(function($exception) {
+        $h = new handler();
+        $h->handle($exception);
+});
+
+throw new Exception('exception');
+?>
+--EXPECT--
+exception
index 989e2a6d5928431eb1018a5c92010f0d299b2e94..ac68702d70a0cad4f086fc7298c507db4dd5bbf7 100644 (file)
@@ -1781,20 +1781,20 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
                                        zval *orig_user_exception_handler;
                                        zval **params[1], *retval2, *old_exception;
                                        old_exception = EG(exception);
-                                       zend_exception_save(TSRMLS_C);
+                                       EG(exception) = NULL;
                                        params[0] = &old_exception;
                                        orig_user_exception_handler = EG(user_exception_handler);
                                        if (call_user_function_ex(CG(function_table), NULL, orig_user_exception_handler, &retval2, 1, params, 1, NULL TSRMLS_CC) == SUCCESS) {
                                                if (retval2 != NULL) {
                                                        zval_ptr_dtor(&retval2);
                                                }
-                                               zend_exception_restore(TSRMLS_C);
                                                if (EG(exception)) {
                                                        zval_ptr_dtor(&EG(exception));
                                                        EG(exception) = NULL;
                                                }
+                                               zval_ptr_dtor(&old_exception);
                                        } else {
-                                               zend_exception_restore(TSRMLS_C);
+                                               EG(exception) = old_exception;
                                                zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
                                        }
                                } else {