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 01/11] parse-events: Free flag/sym field on failure path
    Date
    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;
    field->value = strdup(value);
    if (field->value == NULL)
    - goto out_free;
    + goto out_free_field;

    free_arg(arg);
    arg = alloc_arg();
    @@ -2177,14 +2177,14 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
    free_token(token);
    type = process_arg(event, arg, &token);
    if (test_type_token(type, token, EVENT_OP, "}"))
    - goto out_free;
    + goto out_free_field_value;

    value = arg_eval(arg);
    if (value == NULL)
    - goto out_free;
    + goto out_free_field_value;
    field->str = strdup(value);
    if (field->str == NULL)
    - goto out_free;
    + goto out_free_field_value;
    free_arg(arg);
    arg = NULL;

    @@ -2198,6 +2198,10 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
    *tok = token;
    return type;

    +out_free_field_value:
    + free(field->value);
    +out_free_field:
    + free(field);
    out_free:
    free_arg(arg);
    free_token(token);
    --
    1.7.10


    \
     
     \ /
      Last update: 2012-04-23 07:39    [W:2.775 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site