summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2010-04-01 19:36:56 +0000
committerStanislav Malyshev <stas@php.net>2010-04-01 19:36:56 +0000
commita3857fd9631102cbe923cca8fce0d22a4c5c3199 (patch)
tree3da16475f401caa3b5dcdf47606cd85eac2beff6
parent8b1d84a6ce59b89fa593c110f3aa71ac12b55b1d (diff)
downloadphp-git-a3857fd9631102cbe923cca8fce0d22a4c5c3199.tar.gz
fix #51394 - try harder to find script lineno when exception happens
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug51394.phpt16
-rw-r--r--Zend/zend_execute_API.c4
3 files changed, 22 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 014d3d3ad6..513489aded 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ PHP NEWS
- Fixed a NULL pointer dereference when processing invalid XML-RPC
requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert)
+- Fixed bug #51394 (Error line reported incorrectly if error handler throws an
+ exception). (Stas)
- Fixed bug #51393 (DateTime::createFromFormat() fails if format string contains
timezone). (Adam)
- Fixed bug #51347 (mysqli_close / connection memory leak). (Andrey, Johannes)
diff --git a/Zend/tests/bug51394.phpt b/Zend/tests/bug51394.phpt
new file mode 100644
index 0000000000..537574c9d5
--- /dev/null
+++ b/Zend/tests/bug51394.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #51394 (Error line reported incorrectly if error handler throws an exception)
+--INI--
+error_reporting=-1
+--FILE--
+<?php
+function eh()
+{
+ throw new Exception("error!");
+ return false;
+}
+
+set_error_handler("eh");
+$a = $empty($b);
+--EXPECTF--
+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_execute_API.c b/Zend/zend_execute_API.c
index 55d0ab72ca..1865b6cbf9 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -411,6 +411,10 @@ ZEND_API char *zend_get_executed_filename(TSRMLS_D) /* {{{ */
ZEND_API uint zend_get_executed_lineno(TSRMLS_D) /* {{{ */
{
+ if(EG(exception) && EG(opline_ptr) && active_opline->opcode == ZEND_HANDLE_EXCEPTION &&
+ active_opline->lineno == 0 && EG(opline_before_exception)) {
+ return EG(opline_before_exception)->lineno;
+ }
if (EG(opline_ptr)) {
return active_opline->lineno;
} else {