From: Michael Snyder Date: Wed, 9 Mar 2011 20:31:50 +0000 (+0000) Subject: 2011-03-09 Michael Snyder X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=85c9d6a63284a825f5c174f80d272b4aa19bc828;p=binutils-gdb.git 2011-03-09 Michael Snyder * mi-cmd-disas.c (mi_cmd_disassemble): Fix memory leak. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c263053acd8..c6472e873fc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2011-03-09 Michael Snyder + + * mi-cmd-disas.c (mi_cmd_disassemble): Fix memory leak. + 2011-03-09 Pedro Alves * nto-tdep.c (nto_find_and_open_solib): Constify local `base'. diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c index bfe1769ed1b..28e84f661d8 100644 --- a/gdb/mi/mi-cmd-disas.c +++ b/gdb/mi/mi-cmd-disas.c @@ -73,6 +73,7 @@ mi_cmd_disassemble (char *command, char **argv, int argc) int how_many = -1; CORE_ADDR low = 0; CORE_ADDR high = 0; + struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); /* Options processing stuff. */ int optind = 0; @@ -103,6 +104,7 @@ mi_cmd_disassemble (char *command, char **argv, int argc) case FILE_OPT: file_string = xstrdup (optarg); file_seen = 1; + make_cleanup (xfree, file_string); break; case LINE_OPT: line_num = atoi (optarg); @@ -169,4 +171,6 @@ mi_cmd_disassemble (char *command, char **argv, int argc) file_string, disasm_flags, how_many, low, high); + + do_cleanups (cleanups); }