From: Chen Gang Date: Fri, 30 Jan 2015 22:06:38 +0000 (+0800) Subject: sim: Be sure of calling freeargv() after successfully call buildargv(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cd71915c7738f0992daefe0320b10e3b1960535c;p=binutils-gdb.git sim: Be sure of calling freeargv() after successfully call buildargv(). Or there will be memory leak. 2015-02-02 Chen Gang * mcore/interp.c (sim_do_command): Call freeargv() before return. --- diff --git a/sim/ChangeLog b/sim/ChangeLog index 9ddee6482df..628e6a8b09f 100644 --- a/sim/ChangeLog +++ b/sim/ChangeLog @@ -1,3 +1,7 @@ +2015-02-02 Chen Gang + + * mcore/interp.c (sim_do_command): Call freeargv() before return. + 2015-02-02 Chen Gang * common/sim-options.c (sim_args_command): Call freeargv() when diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index d2edd126c3f..dfaa6aacbd0 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -2143,6 +2143,7 @@ sim_do_command (sd, cmd) if ((simargv[1] == NULL) || (simargv[2] == NULL)) { fprintf (stderr, "Error: missing argument to watch cmd.\n"); + freeargv (simargv); return; } @@ -2187,6 +2188,8 @@ sim_do_command (sd, cmd) fprintf (stderr,"Error: \"%s\" is not a valid M.CORE simulator command.\n", cmd); } + + freeargv (simargv); } else {