From patchwork Mon Feb 2 20:15:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 4889 Received: (qmail 22246 invoked by alias); 2 Feb 2015 20:08:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22237 invoked by uid 89); 2 Feb 2015 20:08:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: out2130-205.mail.aliyun.com Received: from out2130-205.mail.aliyun.com (HELO out2130-205.mail.aliyun.com) (42.156.130.205) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Feb 2015 20:08:06 +0000 X-Alimail-AntiSpam: AC=AD; BC=0.8754417|0.1365118; BR=01201311R131b1; FP=0|0|0|0|0|-1|-1|-1; HT=r46d02013; MF=gang.chen@sunrus.com.cn; PH=DS; RN=2; RT=2; SR=0; Received: from ShengShiZhuChengdeMacBook-Pro.local(mailfrom:gang.chen@sunrus.com.cn ip:223.72.65.34) by smtp.aliyun-inc.com(10.147.34.67); Tue, 03 Feb 2015 04:08:01 +0800 Message-ID: <54CFDAF2.5050904@sunrus.com.cn> Date: Tue, 03 Feb 2015 04:15:46 +0800 From: Chen Gang S User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org, Michael Eager Subject: [PATCH v2] sim: Be sure of calling freeargv() after successfully call buildargv(). Or there will be memory leak. 2015-02-02 Chen Gang * 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 @@ 2015-02-02 Chen Gang + * microblaze/interp.c (sim_do_command): Call freeargv() before + return. + +2015-02-02 Chen Gang + * mcore/interp.c (sim_do_command): Call freeargv() before return. 2015-02-02 Chen Gang 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 {