[xdebug-dev] xdebug xdebug/xdebug.c xdebug/tests/bug00340.phpt - Fixed bug #340: Segfault while throwing an Exception.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Thu, 9 Jul 2009 18:51:44 +0200

Date: Thu Jul 9 18:51:44 CEST 2009
User: Derick Rethans
Directory: xdebug

Log Message:
[1.50]
- Fixed bug #340: Segfault while throwing an Exception.

Modified files:
           xdebug/xdebug.c (version: 1.454)
Added files:
           xdebug/tests/bug00340.phpt (new version: 1.1)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.453
retrieving revision 1.454
diff -u -r1.453 -r1.454
--- xdebug/xdebug.c:1.453 Mon Jul 06 07:34:25 2009 GMT
+++ xdebug/xdebug.c Thu Jul 09 14:51:44 2009 GMT
@@ -2397,6 +2397,10 @@
         file = zend_read_property(default_ce, exception, "file", sizeof("file")-1, 0 TSRMLS_CC);
         line = zend_read_property(default_ce, exception, "line", sizeof("line")-1, 0 TSRMLS_CC);
 
+ if (Z_TYPE_P(message) != IS_STRING || Z_TYPE_P(file) != IS_STRING || Z_TYPE_P(line) != IS_LONG) {
+ php_error(E_ERROR, "Your exception class uses incorrect types for common properties: 'message' and 'file' need to be a string and 'line' needs to be an integer.");
+ }
+
         exception_trace = get_printable_stack(PG(html_errors), exception_ce->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line) TSRMLS_CC);
         if (XG(last_exception_trace)) {
                 xdfree(XG(last_exception_trace));

[FILE: /xdebug/tests/bug00340.phpt]

--TEST--
Test for bug #340 (Segfault while throwing an Exception)
--INI--
xdebug.default_enable=1
html_errors=1
--FILE--
<?php
class MyException extends Exception
{
        function __construct()
        {
                $this->message = new StdClass;
        }
}

throw new MyException();
?>
--EXPECTF--
<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Your exception class uses incorrect types for common properties: 'message' and 'file' need to be a string and 'line' needs to be an integer. in %sbug00340.php on line <i>11</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00340.php' bgcolor='#eeeeec'>../bug00340.php<b>:</b>0</td></tr>
</table></font>
Received on Thu Jul 09 2009 - 18:52:10 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST