svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug51394.phpt branches/PHP_5_3/Zend/zend_execute_API.c
trunk/Zend/tests/bug51394.phpt trunk/Zend/zend_execute_API.c
| From: | Stanislav Malyshev | Date: | Thu, 01 Apr 2010 19:36:56 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug51394.phpt branches/PHP_5_3/Zend/zend_execute_API.c trunk/Zend/tests/bug51394.phpt trunk/Zend/zend_execute_API.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-62182@lists.php.net to get a copy of this message | ||
stas Thu, 01 Apr 2010 19:36:56 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=297301
Log:
fix #51394 - try harder to find script lineno when exception happens
Bug: http://bugs.php.net/51394 (Open) Error line reported
incorrectly iif error handler throws an exception
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/Zend/tests/bug51394.phpt
U php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c
A php/php-src/trunk/Zend/tests/bug51394.phpt
U php/php-src/trunk/Zend/zend_execute_API.c
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-04-01 18:04:57 UTC (rev 297300)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-04-01 19:36:56 UTC (rev 297301)
@@ -11,6 +11,8 @@
- 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)
Added: php/php-src/branches/PHP_5_3/Zend/tests/bug51394.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug51394.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug51394.phpt 2010-04-01 19:36:56 UTC (rev 297301)
@@ -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
Modified: php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c 2010-04-01 18:04:57 UTC (rev 297300)
+++ php/php-src/branches/PHP_5_3/Zend/zend_execute_API.c 2010-04-01 19:36:56 UTC (rev 297301)
@@ -411,6 +411,10 @@
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 {
Added: php/php-src/trunk/Zend/tests/bug51394.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug51394.phpt (rev 0)
+++ php/php-src/trunk/Zend/tests/bug51394.phpt 2010-04-01 19:36:56 UTC (rev 297301)
@@ -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
Modified: php/php-src/trunk/Zend/zend_execute_API.c
===================================================================
--- php/php-src/trunk/Zend/zend_execute_API.c 2010-04-01 18:04:57 UTC (rev 297300)
+++ php/php-src/trunk/Zend/zend_execute_API.c 2010-04-01 19:36:56 UTC (rev 297301)
@@ -411,6 +411,10 @@
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 {