From patchwork Mon Feb 2 20:14:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 4888 Received: (qmail 20586 invoked by alias); 2 Feb 2015 20:06:48 -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 20571 invoked by uid 89); 2 Feb 2015 20:06:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: out1134-210.mail.aliyun.com Received: from out1134-210.mail.aliyun.com (HELO out1134-210.mail.aliyun.com) (42.120.134.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Feb 2015 20:06:47 +0000 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.3915498|-1; FP=0|0|0|0|0|-1|-1|-1; HT=r46d02012; MF=gang.chen@sunrus.com.cn; PH=DS; RN=1; RT=1; 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.38.26); Tue, 03 Feb 2015 04:06:44 +0800 Message-ID: <54CFDAA5.2030603@sunrus.com.cn> Date: Tue, 03 Feb 2015 04:14:29 +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 Subject: [PATCH v2] 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. --- 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 @@ 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 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 {