diff options
Diffstat (limited to 'sapi/phpdbg/phpdbg_list.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index 6895bea43e..dd0187cfbe 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -200,11 +200,12 @@ void phpdbg_list_function_byname(const char *str, size_t len) /* {{{ */ /* search active scope if begins with period */ if (func_name[0] == '.') { - if (EG(scope)) { + zend_class_entry *scope = zend_get_executed_scope(); + if (scope) { func_name++; func_name_len--; - func_table = &EG(scope)->function_table; + func_table = &scope->function_table; } else { phpdbg_error("inactive", "type=\"noclasses\"", "No active class"); return; @@ -316,6 +317,17 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) { dataptr = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), filename, strlen(filename)); ZEND_ASSERT(dataptr != NULL); + if (op_array->vars) { + int i; + /* un-intern these strings to prevent zend_interned_strings_restore from invalidating our string pointers too early (in phpdbg allocated memory only gets freed after module shutdown) */ + for (i = 0; i < op_array->last_var; i++) { + zend_string **s = op_array->vars + i; + if (ZSTR_IS_INTERNED(*s)) { + *s = zend_string_init(ZSTR_VAL(*s), ZSTR_LEN(*s), 0); + } + } + } + dataptr->op_array = *op_array; if (dataptr->op_array.refcount) { ++*dataptr->op_array.refcount; @@ -371,22 +383,9 @@ zend_op_array *phpdbg_compile_string(zval *source_string, char *filename) { return op_array; } -void phpdbg_free_file_source(zval *zv) { - phpdbg_file_source *data = Z_PTR_P(zv); - - if (data->buf) { - efree(data->buf); - } - - destroy_op_array(&data->op_array); - - efree(data); -} - void phpdbg_init_list(void) { PHPDBG_G(compile_file) = zend_compile_file; PHPDBG_G(compile_string) = zend_compile_string; - zend_hash_init(&PHPDBG_G(file_sources), 1, NULL, (dtor_func_t) phpdbg_free_file_source, 0); zend_compile_file = phpdbg_compile_file; zend_compile_string = phpdbg_compile_string; } |