Browse files

Add extra checks whether variables have been set.

This solves some crashes, although it produces weird results in PHP 5.5 a
little still.
  • Loading branch information...
1 parent 1d7c6b6 commit 12ea3272fa51431d25afdc93de7d8d5bfb38c077 @derickr committed Nov 24, 2012
Showing with 16 additions and 3 deletions.
  1. +1 −1 xdebug.c
  2. +15 −2 xdebug_stack.c
View
2 xdebug.c
@@ -1552,7 +1552,7 @@ void xdebug_execute_internal(zend_execute_data *current_execute_data, struct _ze
xdebug_trace_function_end(fse, function_nr TSRMLS_CC);
/* Store return value in the trace file */
- if (XG(collect_return) && do_return && XG(do_trace) && XG(trace_file)) {
+ if (XG(collect_return) && do_return && XG(do_trace) && XG(trace_file) && EG(opline_ptr)) {
cur_opcode = *EG(opline_ptr);
if (cur_opcode) {
zval *ret = xdebug_zval_ptr(cur_opcode->XDEBUG_TYPE(result), &(cur_opcode->result), current_execute_data->Ts TSRMLS_CC);
View
17 xdebug_stack.c
@@ -963,7 +963,11 @@ function_stack_entry *xdebug_add_stack_frame(zend_execute_data *zdata, zend_op_a
if (edata && edata->op_array) {
/* Normal function calls */
tmp->filename = xdstrdup(edata->op_array->filename);
- } else if (edata && edata->prev_execute_data && XDEBUG_LLIST_TAIL(XG(stack))
+ } else if (
+ edata &&
+ edata->prev_execute_data &&
+ XDEBUG_LLIST_TAIL(XG(stack)) &&
+ ((function_stack_entry*) XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))))->filename
) {
tmp->filename = xdstrdup(((function_stack_entry*) XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))))->filename);
}
@@ -973,9 +977,18 @@ function_stack_entry *xdebug_add_stack_frame(zend_execute_data *zdata, zend_op_a
tmp->filename = (op_array && op_array->filename) ? xdstrdup(op_array->filename): NULL;
}
/* Call user function locations */
- if (!tmp->filename && XDEBUG_LLIST_TAIL(XG(stack)) && XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))) ) {
+ if (
+ !tmp->filename &&
+ XDEBUG_LLIST_TAIL(XG(stack)) &&
+ XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))) &&
+ ((function_stack_entry*) XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))))->filename
+ ) {
tmp->filename = xdstrdup(((function_stack_entry*) XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))))->filename);
}
+
+ if (!tmp->filename) {
+ tmp->filename = xdstrdup("UNKNOWN?");
+ }
#if HAVE_PHP_MEMORY_USAGE
tmp->prev_memory = XG(prev_memory);
tmp->memory = XG_MEMORY_USAGE();

0 comments on commit 12ea327

Please sign in to comment.