diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-07-21 10:20:34 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-07-21 10:20:34 +0200 |
commit | 0077d02c8682826a21852963fd4bf97beee9b105 (patch) | |
tree | 62fe8ba323d64a43614c4846f89298db15882e29 /src | |
parent | 86281072f9b943c23119f1c90cd33934caf1d737 (diff) | |
download | profani-tty-0077d02c8682826a21852963fd4bf97beee9b105.tar.gz |
parse_args(): Call g_free() once
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/parser.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/tools/parser.c b/src/tools/parser.c index 2e1d5c98..9818c178 100644 --- a/src/tools/parser.c +++ b/src/tools/parser.c @@ -132,12 +132,13 @@ parse_args(const char* const inp, int min, int max, gboolean* result) tokens = g_slist_append(tokens, g_strndup(token_start, token_size)); } + free(copy); + int num = g_slist_length(tokens) - 1; // if num args not valid return NULL if ((num < min) || (num > max)) { g_slist_free_full(tokens, free); - g_free(copy); *result = FALSE; return NULL; @@ -146,7 +147,6 @@ parse_args(const char* const inp, int min, int max, gboolean* result) g_slist_free_full(tokens, free); gchar** args = malloc((num + 1) * sizeof(*args)); args[0] = NULL; - g_free(copy); *result = TRUE; return args; @@ -164,7 +164,6 @@ parse_args(const char* const inp, int min, int max, gboolean* result) args[arg_count] = NULL; g_slist_free_full(tokens, free); - g_free(copy); *result = TRUE; return args; } |