Patch bug61767.diff for Scripting Engine problem Bug #61767
Patch version 2012-09-05 08:14 UTC
Return to Bug #61767 |
Download this patch
Patch Revisions:
Developer: dmitry@php.net
diff --git a/Zend/tests/bug51394.phpt b/Zend/tests/bug51394.phpt
index 537574c..406de13 100644
--- a/Zend/tests/bug51394.phpt
+++ b/Zend/tests/bug51394.phpt
@@ -13,4 +13,10 @@ function eh()
set_error_handler("eh");
$a = $empty($b);
--EXPECTF--
+Warning: Uncaught exception 'Exception' with message 'error!' in %sbug51394.php:4
+Stack trace:
+#0 %sbug51394.php(9): eh(8, 'Undefined varia...', '%s', 9, Array)
+#1 {main}
+ thrown in %sbug51394.php on line 4
+
Fatal error: Function name must be a string in %sbug51394.php on line 9
\ No newline at end of file
diff --git a/Zend/zend.c b/Zend/zend.c
index ea32346..bd53d55 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -997,6 +997,29 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
zend_stack labels_stack;
TSRMLS_FETCH();
+ /* Report about uncaught exception in case of fatal errors */
+ if (EG(exception)) {
+ switch (type) {
+ case E_CORE_ERROR:
+ case E_ERROR:
+ case E_RECOVERABLE_ERROR:
+ case E_PARSE:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ if (zend_is_executing(TSRMLS_C)) {
+ error_lineno = zend_get_executed_lineno(TSRMLS_C);
+ }
+ zend_exception_error(EG(exception), E_WARNING TSRMLS_CC);
+ EG(exception) = NULL;
+ if (zend_is_executing(TSRMLS_C) && EG(opline_ptr)) {
+ active_opline->lineno = error_lineno;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
/* Obtain relevant filename and lineno */
switch (type) {
case E_CORE_ERROR:
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 288a5df..eae47d9 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1272,6 +1272,7 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
if (retval) {
zval_ptr_dtor(&retval);
}
+ EG(exception) = NULL;
zend_error(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name);
return FAILURE;
}
|