From 202c1cee3971279c589f4cd01772bf720bcfc05d Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Fri, 22 Nov 2013 19:16:25 +0100 Subject: [PATCH] Fixed segfault + ZTS --- phpdbg_frame.c | 7 ++++--- phpdbg_frame.h | 4 ++-- phpdbg_prompt.c | 8 ++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/phpdbg_frame.c b/phpdbg_frame.c index aeda9ed303..536debfe01 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -28,7 +28,7 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg); #define PHPDBG_FRAME(v) (PHPDBG_G(frame).v) #define PHPDBG_EX(v) (EG(current_execute_data)->v) -void switch_to_frame(int frame) { +void switch_to_frame(int frame TSRMLS_DC) { zend_execute_data *execute_data = PHPDBG_FRAME(num)?PHPDBG_FRAME(execute_data):EG(current_execute_data); int i = 0; @@ -52,7 +52,7 @@ void switch_to_frame(int frame) { return; } - restore_frame(); + restore_frame(TSRMLS_C); if (frame > 0) { PHPDBG_FRAME(num) = frame; @@ -63,6 +63,7 @@ void switch_to_frame(int frame) { EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); + PHPDBG_FRAME(execute_data)->original_return_value = EG(return_value_ptr_ptr); EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); EG(active_symbol_table) = PHPDBG_EX(symbol_table); EG(This) = PHPDBG_EX(current_this); @@ -80,7 +81,7 @@ void switch_to_frame(int frame) { ); } -void restore_frame() { +void restore_frame(TSRMLS_D) { if (PHPDBG_FRAME(num) == 0) { return; } diff --git a/phpdbg_frame.h b/phpdbg_frame.h index 39efbf18f3..49cdbcfe70 100644 --- a/phpdbg_frame.h +++ b/phpdbg_frame.h @@ -29,8 +29,8 @@ typedef struct { zend_execute_data *execute_data; } phpdbg_frame; -void switch_to_frame(int frame); +void switch_to_frame(int frame TSRMLS_DC); -void restore_frame(); +void restore_frame(TSRMLS_D); #endif /* PHPDBG_FRAME_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 27f0b73991..a5dca20113 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -376,7 +376,7 @@ PHPDBG_COMMAND(frame) /* {{{ */ { switch (param->type) { case NUMERIC_PARAM: - switch_to_frame(param->num); + switch_to_frame(param->num TSRMLS_CC); break; case EMPTY_PARAM: @@ -1077,7 +1077,11 @@ last: out: phpdbg_destroy_input(&input TSRMLS_CC); - + + if (EG(in_execution)) { + restore_frame(TSRMLS_C); + } + PHPDBG_G(flags) &= ~PHPDBG_IS_INTERACTIVE; return ret; -- 2.40.0