public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Chen Gang S <gang.chen@sunrus.com.cn>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: Be sure of calling freeargv() after successfully call buildargv().
Date: Sat, 31 Jan 2015 11:56:00 -0000	[thread overview]
Message-ID: <54CC0E99.1070501@sunrus.com.cn> (raw)

Or there will be memory leak.

2014-01-31  Chen Gang <gang.chen.5i5j@gmail.com>

	* microblaze/interp.c (sim_do_command): Call freeargv() before
	return.
---
 sim/ChangeLog           | 5 +++++
 sim/microblaze/interp.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/sim/ChangeLog b/sim/ChangeLog
index 1fe93df..582bd4a 100644
--- a/sim/ChangeLog
+++ b/sim/ChangeLog
@@ -1,5 +1,10 @@
 2014-01-31  Chen Gang <gang.chen.5i5j@gmail.com>
 
+	* microblaze/interp.c (sim_do_command): Call freeargv() before
+	return.
+
+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>
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 1c8a22d..4fc4595 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -1019,6 +1019,7 @@ sim_do_command (SIM_DESC sd, const char *cmd)
 	  if ((simargv[1] == NULL) || (simargv[2] == NULL))
 	    {
 	      fprintf (stderr, "Error: missing argument to watch cmd.\n");
+	      freeargv (simargv);
 	      return;
 	    }
 
@@ -1062,6 +1063,8 @@ sim_do_command (SIM_DESC sd, const char *cmd)
 	  fprintf (stderr,"Error: \"%s\" is not a valid M.CORE simulator command.\n",
 		   cmd);
 	}
+
+      freeargv (simargv);
     }
   else
     {
-- 
1.9.3

             reply	other threads:[~2015-01-30 22:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-31 11:56 Chen Gang S [this message]
2015-01-31 18:46 ` Michael Eager
2015-02-02 19:38   ` Chen Gang S
2015-02-03  2:50     ` Joel Brobecker
2015-02-03  9:58       ` Chen Gang S
2015-02-17 10:34 ` Mike Frysinger
2015-02-17 23:10   ` Chen Gang S
2015-02-18  0:22     ` Mike Frysinger
2015-02-19  0:34       ` Chen Gang S
2015-02-19 15:53         ` Michael Eager
  -- strict thread matches above, loose matches on Subject: below --
2015-01-31  8:59 Chen Gang S
2015-01-28 15:53 Chen Gang S
2015-01-28 20:43 ` Michael Eager
2015-01-29  4:53   ` Chen Gang S
2015-01-29  5:01     ` Michael Eager
2015-01-29  5:11       ` Chen Gang S
2015-02-17 10:36     ` Mike Frysinger
2015-01-29  7:03 ` Joel Brobecker
2015-01-29  7:28   ` Chen Gang S

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54CC0E99.1070501@sunrus.com.cn \
    --to=gang.chen@sunrus.com.cn \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).