From da065d6fb2ad54450daf8f1b50d2934c6880a546 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Mon, 11 Nov 2013 15:14:37 +0000 Subject: [PATCH] no estrdup on opline breakpoints --- phpdbg.c | 18 +++++++++++++++--- phpdbg_bp.c | 2 +- test.php | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 2845add3c0..351bdc6ba2 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -65,7 +65,7 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */ static void php_phpdbg_destroy_bp_opline(void *brake) /* {{{ */ { - efree((char*)((phpdbg_breakline_t*)brake)->name); + free((char*)((phpdbg_breakline_t*)brake)->name); } /* }}} */ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ @@ -94,17 +94,29 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ return SUCCESS; } /* }}} */ -static PHP_FUNCTION(phpdbg_break) /* {{{ */ +/* {{{ proto void phpdbg_break(void) + instructs phpdbg to insert a breakpoint at the next opcode */ +static PHP_FUNCTION(phpdbg_break) { if (EG(current_execute_data) && EG(active_op_array)) { - zend_ulong opline_num = EG(current_execute_data)->opline - EG(active_op_array)->opcodes; + zend_ulong opline_num = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes); phpdbg_set_breakpoint_opline_ex( &EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC); } } /* }}} */ +/* {{{ proto void phpdbg_clear(void) + instructs phpdbg to clear breakpoints */ +static PHP_FUNCTION(phpdbg_clear) +{ + zend_hash_clean(&PHPDBG_G(bp_files)); + zend_hash_clean(&PHPDBG_G(bp_symbols)); + zend_hash_clean(&PHPDBG_G(bp_oplines)); +} /* }}} */ + zend_function_entry phpdbg_user_functions[] = { + PHP_FE(phpdbg_clear, NULL) PHP_FE(phpdbg_break, NULL) #ifdef PHP_FE_END PHP_FE_END diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 2bbb12f44b..6f615992d0 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -92,7 +92,7 @@ void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */ PHPDBG_G(has_opline_bp) = 1; - new_break.name = estrdup(name); + new_break.name = strdup(name); new_break.opline = opline; new_break.id = PHPDBG_G(bp_count)++; diff --git a/test.php b/test.php index 3ac566ce76..938d7d8323 100644 --- a/test.php +++ b/test.php @@ -1,6 +1,10 @@