lkml.org 
[lkml]   [2012]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 01/11] parse-events: Free flag/sym field on failure path
Date
Hi,

On Mon, 23 Apr 2012 12:21:06 -0400, Steven Rostedt wrote:
> On Mon, 2012-04-23 at 13:58 +0900, Namhyung Kim wrote:
>> If parsing flag/sym field failed after allocating it, it
>> should be freed.
>>
>> Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
>> ---
>> parse-events.c | 14 +++++++++-----
>> 1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/parse-events.c b/parse-events.c
>> index bd078ba..81e6581 100644
>> --- a/parse-events.c
>> +++ b/parse-events.c
>> @@ -2166,10 +2166,10 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
>>
>> value = arg_eval(arg);
>> if (value == NULL)
>> - goto out_free;
>> + goto out_free_field;
>
> Instead of adding more goto's what, before the first goto "out_free"
> add:
>
> field = NULL;
>
> and since the field is allocated and also memset to zero, we could do in
> the out_free:
>
> if (field) {
> free(field->value);
> free(field);
> }
>
> I think that would be cleaner.
>
> -- Steve
>

OK, will resend v2.

Thanks,
Namhyung


\
 
 \ /
  Last update: 2012-04-24 02:09    [W:1.050 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site