This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [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: Michael Eager <eager at eagerm dot com>, gdb-patches at sourceware dot org
- Cc: binutils at sourceware dot org
- Date: Thu, 29 Jan 2015 09:44:22 +0800
- Subject: Re: [PATCH] sim: Be sure of calling freeargv() after successfully call buildargv().
- Authentication-results: sourceware.org; auth=none
- References: <54C8CBC8 dot 90102 at sunrus dot com dot cn> <54C905FE dot 6020207 at eagerm dot com> <54C9607B dot 5060304 at sunrus dot com dot cn> <54C978FF dot 8010303 at eagerm dot com>
On 1/29/15 08:04, Michael Eager wrote:
> On 01/28/15 14:19, Chen Gang S wrote:
>> 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 <gang.chen.5i5j@gmail.com>
>>>>
>>>> * 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().
>>
Oh, sorry, the 3rd sentence is incorrect, it should be:
"Except the above 2, for me, there are no any other places to cause
buildargv() related issues or doubts".
>>
>> Does the patch comments need to mention about the contents above?
>
> No, you don't need to mention what is not modified.
>
>
OK, thanks.
--
Chen Gang
Open, share, and attitude like air, water, and life which God blessed