From 823aca91eec1b7525b74b9cd66ae286c37f2da75 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 5 May 2014 10:24:16 +0300 Subject: Fix debugger 'run' command to fully restart. --- debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index b55f3577..84e69d47 100644 --- a/debug.c +++ b/debug.c @@ -2801,7 +2801,7 @@ debug_prog(INSTRUCTION *pc) unserialize(OPTION); unsetenv("DGAWK_RESTART"); fprintf(out_fp, "Restarting ...\n"); - if (run[0] == 'T') + if (strcasecmp(run, "true") == 0) (void) do_run(NULL, 0); } else if (command_file != NULL) { -- cgit v1.2.3 From 123402fa15ec56d510ddd4cba16a5aea88e18023 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 9 May 2014 11:39:05 +0300 Subject: Fix double free error in do_eval. --- debug.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 84e69d47..1ff43bd6 100644 --- a/debug.c +++ b/debug.c @@ -5565,8 +5565,16 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) pop_context(); /* switch to prev context */ free_context(ctxt, (ret_val != NULL)); /* free all instructions and optionally symbols */ - if (ret_val != NULL) - destroy_symbol(f); /* destroy "@eval" */ + + /* + * May 2014: + * Don't do this. f points into the context we just released. + * Only showed up on Fedora 20 / Ubuntu 14.04. + * + * if (ret_val != NULL) + * destroy_symbol(f); // destroy "@eval" + */ + return false; } -- cgit v1.2.3 From 12857707435f1d4bf9adf33b6fbfd57ff91529a7 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 9 May 2014 11:42:52 +0300 Subject: Fix memory leak in do_eval. --- debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 1ff43bd6..32b308af 100644 --- a/debug.c +++ b/debug.c @@ -5448,6 +5448,7 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) int ecount = 0, pcount = 0; int ret; int save_flags = do_flags; + SRCFILE *the_source; if (prog_running) { this_frame = find_frame(0); @@ -5458,7 +5459,7 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) ctxt = new_context(); ctxt->install_func = append_symbol; /* keep track of newly installed globals */ push_context(ctxt); - (void) add_srcfile(SRC_CMDLINE, arg->a_string, srcfiles, NULL, NULL); + the_source = add_srcfile(SRC_CMDLINE, arg->a_string, srcfiles, NULL, NULL); do_flags = false; ret = parse_program(&code); do_flags = save_flags; @@ -5575,6 +5576,8 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) * destroy_symbol(f); // destroy "@eval" */ + free_srcfile(the_source); + return false; } -- cgit v1.2.3 From 35de6ecfbbc272f25d12370785b1032447f37164 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 11 May 2014 05:22:51 +0300 Subject: Further fix to eval "" in debugger. --- debug.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 32b308af..5d7db01b 100644 --- a/debug.c +++ b/debug.c @@ -5560,21 +5560,24 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) this_func->param_cnt -= ecount; } - /* always destroy symbol "@eval", however destroy all newly installed + /* + * Always destroy symbol "@eval", however destroy all newly installed * globals only if fatal error (execute_code() returing NULL). */ pop_context(); /* switch to prev context */ free_context(ctxt, (ret_val != NULL)); /* free all instructions and optionally symbols */ - /* - * May 2014: - * Don't do this. f points into the context we just released. - * Only showed up on Fedora 20 / Ubuntu 14.04. - * - * if (ret_val != NULL) - * destroy_symbol(f); // destroy "@eval" - */ + if (ret_val != NULL) { + /* + * Remove @eval from FUNCTAB, so that above code + * will work the next time around. + */ + NODE *s = make_string("@eval", 5); + + (void) assoc_remove(func_table, s); + unref(s); + } free_srcfile(the_source); -- cgit v1.2.3