This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] sim: Be sure of calling freeargv() after successfully call buildargv().
- From: Chen Gang S <gang dot chen at sunrus dot com dot cn>
- To: gdb-patches at sourceware dot org
- Date: Sat, 31 Jan 2015 07:05:43 +0800
- Subject: [PATCH] sim: Be sure of calling freeargv() after successfully call buildargv().
- Authentication-results: sourceware.org; auth=none
Or there will be memory leak.
2015-01-31 Chen Gang <gang.chen.5i5j@gmail.com>
* mcore/interp.c (sim_do_command): Call freeargv() before return.
---
sim/ChangeLog | 4 ++++
sim/mcore/interp.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/sim/ChangeLog b/sim/ChangeLog
index 7153c6a..1fe93df 100644
--- a/sim/ChangeLog
+++ b/sim/ChangeLog
@@ -1,5 +1,9 @@
2014-01-31 Chen Gang <gang.chen.5i5j@gmail.com>
+ * mcore/interp.c (sim_do_command): Call freeargv() before return.
+
+2014-01-31 Chen Gang <gang.chen.5i5j@gmail.com>
+
* common/sim-options.c (sim_args_command): Call freeargv() when
failure occurs.
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index d2edd12..dfaa6aa 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
{
--
1.9.3