From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19443 invoked by alias); 28 Jan 2015 22:12:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 19419 invoked by uid 89); 28 Jan 2015 22:12:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_40,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: out1134-250.mail.aliyun.com Received: from out1134-250.mail.aliyun.com (HELO out1134-250.mail.aliyun.com) (42.120.134.250) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Jan 2015 22:12:02 +0000 X-Alimail-AntiSpam:AC=CONTINUE;BC=0.2520103|-1;FP=0|0|0|0|0|-1|-1|-1;HT=r41f05015;MF=gang.chen@sunrus.com.cn;PH=DS;RN=3;RT=3;SR=0; Received: from ShengShiZhuChengdeMacBook-Pro.local(mailfrom:gang.chen@sunrus.com.cn ip:223.72.65.76) by smtp.aliyun-inc.com(10.147.11.246); Thu, 29 Jan 2015 06:11:56 +0800 Message-ID: <54C9607B.5060304@sunrus.com.cn> Date: Thu, 29 Jan 2015 04:53:00 -0000 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: Michael Eager , gdb-patches@sourceware.org CC: binutils@sourceware.org Subject: Re: [PATCH] sim: Be sure of calling freeargv() after successfully call buildargv(). References: <54C8CBC8.90102@sunrus.com.cn> <54C905FE.6020207@eagerm.com> In-Reply-To: <54C905FE.6020207@eagerm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-01/txt/msg00742.txt.bz2 On 1/28/15 23:53, Michael Eager wrote: > On 01/28/15 03:45, Chen Gang S wrote: >> buildargv() and freeargv() are pairs, so need be sure of them always >> paired to avoid memory leak. >> >> 2015-01-28 Chen Gang >> >> * common/sim-options.c (sim_args_command): Call freeargv() when >> failure occurs. >> * mcore/interp.c (sim_do_command): Call freeargv() before return. >> * microblaze/interp.c (sim_do_command): Call freeargv() before >> return. > > > OK for Microblaze. > > There appear to be other places where buildargv() is not followed by > freeargv(). See sim/common/run.c. There may be others. > For me, I intended to skip buildargv() in "sim/common/run.c", because it may contents read only memory. It is in main(), also main() often uses exit(), so I skip it, it doesn't matter. gdb also uses buildargv(), but it just wraps buildargv() and freeargv(), so at least it is another patch (either, at least now, I do not find any issues about it in gdb). Except the above 2, for me, there are no any other places to use buildargv(). Does the patch comments need to mention about the contents above? Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed