summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2009-03-26 10:56:45 +0000
committerDmitry Stogov <dmitry@php.net>2009-03-26 10:56:45 +0000
commitda9405de72b067b4709733083aed29c358117aae (patch)
treefbf15d2da359940b134d5a12472cfc995c8a6751
parentab7f6d88e004b6b5fbc40cdcc174b1c13924b10c (diff)
downloadphp-git-da9405de72b067b4709733083aed29c358117aae.tar.gz
Fixed bug #47714 (autoloading classes inside exception_handler leads to crashes)
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug47714.phpt26
-rw-r--r--Zend/zend.c6
3 files changed, 31 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 096a6e8b8b..c66eaa11b7 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP NEWS
(Matteo)
- Fixed bug #47771 (Exception during object construction from arg call calls
object's destructor). (Dmitry)
+- Fixed bug #47714 (autoloading classes inside exception_handler leads to
+ crashes). (Dmitry)
- Fixed bug #47699 (autoload and late static binding). (Dmitry)
- Fixed bug #47038 (Memory leak in include). (Dmitry)
- Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()). (Matteo)
diff --git a/Zend/tests/bug47714.phpt b/Zend/tests/bug47714.phpt
new file mode 100644
index 0000000000..c784f8fb93
--- /dev/null
+++ b/Zend/tests/bug47714.phpt
@@ -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
diff --git a/Zend/zend.c b/Zend/zend.c
index 44f2c4a9cb..4efcae6615 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1192,20 +1192,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 {