Permalink
Browse files

Fixed issue #1628: The PHP function name being constructed to record …

…when GC Collection runs, is not freed.
  • Loading branch information...
derickr committed Feb 8, 2019
1 parent 83278ea commit 5233246dc94741f4e4b43091f573d8651ef39b8d
Showing with 23 additions and 6 deletions.
  1. +2 −6 xdebug.c
  2. +1 −0 xdebug_gc_stats.c
  3. +18 −0 xdebug_stack.c
  4. +2 −0 xdebug_stack.h
@@ -1078,12 +1078,8 @@ static void function_stack_entry_dtor(void *dummy, void *elem)
e->refcount--;

if (e->refcount == 0) {
if (e->function.function) {
xdfree(e->function.function);
}
if (e->function.class) {
xdfree(e->function.class);
}
xdebug_func_dtor_by_ref(&e->function);

if (e->filename) {
xdfree(e->filename);
}
@@ -88,6 +88,7 @@ int xdebug_gc_collect_cycles(void)
xdebug_gc_stats_print_run(run);

xdebug_gc_stats_run_free(run);
xdebug_func_dtor_by_ref(&tmp);

return ret;
}
@@ -986,6 +986,24 @@ char* xdebug_wrap_closure_location_around_function_name(zend_op_array *opa, char
return tmp.d;
}

/* I don't like this API, but the function_stack_entry does not keep this as a
* pointer, and hence we need two APIs for freeing :-S */
void xdebug_func_dtor_by_ref(xdebug_func *elem)
{
if (elem->function) {
xdfree(elem->function);
}
if (elem->class) {
xdfree(elem->class);
}
}

void xdebug_func_dtor(xdebug_func *elem)
{
xdebug_func_dtor_by_ref(elem);
xdfree(elem);
}

void xdebug_build_fname(xdebug_func *tmp, zend_execute_data *edata TSRMLS_DC)
{
memset(tmp, 0, sizeof(xdebug_func));
@@ -25,6 +25,8 @@

int xdebug_function_name_is_closure(char *fname);
char* xdebug_wrap_closure_location_around_function_name(zend_op_array *opa, char *fname);
void xdebug_func_dtor_by_ref(xdebug_func *elem); /* TODO: Remove this API */
void xdebug_func_dtor(xdebug_func *elem);
void xdebug_build_fname(xdebug_func *tmp, zend_execute_data *edata TSRMLS_DC);
function_stack_entry *xdebug_add_stack_frame(zend_execute_data *zdata, zend_op_array *op_array, int type TSRMLS_DC);
void xdebug_append_error_head(xdebug_str *str, int html, const char *error_type_str TSRMLS_DC);

0 comments on commit 5233246

Please sign in to comment.