lkml.org 
[lkml]   [2012]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] parse-events: Free flag/sym field on failure path
Date
If parsing flag/sym field failed after allocating it, it
should be freed. As Steven advises, make the field NULL
and check it at out_free instead of adding more goto labels.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
---
parse-events.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/parse-events.c b/parse-events.c
index bd078ba..3ccedd9 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -2147,6 +2147,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
if (test_type_token(type, token, EVENT_OP, "{"))
break;

+ field = NULL;
arg = alloc_arg();

free_token(token);
@@ -2199,6 +2200,10 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
return type;

out_free:
+ if (field) {
+ free(field->value);
+ free(field);
+ }
free_arg(arg);
free_token(token);
*tok = NULL;
--
1.7.10


\
 
 \ /
  Last update: 2012-04-24 03:11    [W:0.111 / U:6.136 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site