Skip to content

Commit

Permalink
Merged pull request #268
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Apr 11, 2016
2 parents 61071bc + 0d1021a commit 2bfc498
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
3 changes: 3 additions & 0 deletions tests/bug01266.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
--TEST--
Test for bug #1266: xdebug_dump_superglobals() always dumps empty $_SESSION stack on PHP 7
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
<?php if (!extension_loaded("session")) print "skip session extension not available"; ?>
--INI--
xdebug.dump.SESSION=*
--FILE--
Expand Down
32 changes: 32 additions & 0 deletions tests/bug01288.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
Test for bug #1288: Segfault when uncaught exception message does not contain " in "
--INI--
xdebug.default_enable=1
html_errors=0
xdebug.collect_params=4
--FILE--
<?php

class React_Exception extends Exception
{
public function __toString()
{
return "Custom message";
return "Custom message in random"; // this does not segfault because of ' in '.
}
}

set_error_handler(function(){ throw new React_Exception('waa');});


$_SERVER['SERVER_PROTOCOL'];
?>
--EXPECTF--
Fatal error: Uncaught Custom message
thrown in %sbug01288.php on line 12

React_Exception: waa in %sbug01288.php on line 12

Call Stack:
%w%f %w%d 1. {main}() %sbug01288.php:0
%w%f %w%d 2. {closure:%sbug01288.php:12-12}(8, 'Undefined index: SERVER_PROTOCOL', '%sbug01288.php', %s) %sbug01288.php:15
12 changes: 7 additions & 5 deletions xdebug_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,7 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
char *printable_stack;

/* We need to see if we have an uncaught exception fatal error now */
#if PHP_VERSION_ID >= 70000
if (type == E_ERROR && strncmp(buffer, "Uncaught ", 9) == 0) {
#else
if (type == E_ERROR && strncmp(buffer, "Uncaught exception", 18) == 0) {
#endif
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_buf, *p;

Expand All @@ -782,8 +778,14 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
p = xdebug_strrstr(buffer, " in ");
#else
/* find last quote */
p = ((char *) zend_memrchr(buffer, '\'', p - buffer)) + 1;
p = ((char *) zend_memrchr(buffer, '\'', p - buffer));
if (p) {
p++;
}
#endif
if (!p) {
p = buffer + strlen(buffer);
}
}
/* Create new buffer */
tmp_buf = calloc(p - buffer + 1, 1);
Expand Down

0 comments on commit 2bfc498

Please sign in to comment.