Skip to content

Commit da065d6

Browse files
committed
no estrdup on opline breakpoints
1 parent 632c89b commit da065d6

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

phpdbg.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */
6565

6666
static void php_phpdbg_destroy_bp_opline(void *brake) /* {{{ */
6767
{
68-
efree((char*)((phpdbg_breakline_t*)brake)->name);
68+
free((char*)((phpdbg_breakline_t*)brake)->name);
6969
} /* }}} */
7070

7171
static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
@@ -94,17 +94,29 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
9494
return SUCCESS;
9595
} /* }}} */
9696

97-
static PHP_FUNCTION(phpdbg_break) /* {{{ */
97+
/* {{{ proto void phpdbg_break(void)
98+
instructs phpdbg to insert a breakpoint at the next opcode */
99+
static PHP_FUNCTION(phpdbg_break)
98100
{
99101
if (EG(current_execute_data) && EG(active_op_array)) {
100-
zend_ulong opline_num = EG(current_execute_data)->opline - EG(active_op_array)->opcodes;
102+
zend_ulong opline_num = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
101103

102104
phpdbg_set_breakpoint_opline_ex(
103105
&EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC);
104106
}
105107
} /* }}} */
106108

109+
/* {{{ proto void phpdbg_clear(void)
110+
instructs phpdbg to clear breakpoints */
111+
static PHP_FUNCTION(phpdbg_clear)
112+
{
113+
zend_hash_clean(&PHPDBG_G(bp_files));
114+
zend_hash_clean(&PHPDBG_G(bp_symbols));
115+
zend_hash_clean(&PHPDBG_G(bp_oplines));
116+
} /* }}} */
117+
107118
zend_function_entry phpdbg_user_functions[] = {
119+
PHP_FE(phpdbg_clear, NULL)
108120
PHP_FE(phpdbg_break, NULL)
109121
#ifdef PHP_FE_END
110122
PHP_FE_END

phpdbg_bp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */
9292

9393
PHPDBG_G(has_opline_bp) = 1;
9494

95-
new_break.name = estrdup(name);
95+
new_break.name = strdup(name);
9696
new_break.opline = opline;
9797
new_break.id = PHPDBG_G(bp_count)++;
9898

test.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
2+
phpdbg_clear();
3+
24
function test() {
35
echo "Hello World\n";
6+
$hidden = "variable";
7+
phpdbg_break();
48
}
59
function test2() {
610
echo "Hello World 2\n";

0 commit comments

Comments
 (0)