1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

parse_args(): Call g_free() once

This commit is contained in:
Michael Vetter 2020-07-21 10:20:34 +02:00
parent 86281072f9
commit 0077d02c86

View File

@ -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)); tokens = g_slist_append(tokens, g_strndup(token_start, token_size));
} }
free(copy);
int num = g_slist_length(tokens) - 1; int num = g_slist_length(tokens) - 1;
// if num args not valid return NULL // if num args not valid return NULL
if ((num < min) || (num > max)) { if ((num < min) || (num > max)) {
g_slist_free_full(tokens, free); g_slist_free_full(tokens, free);
g_free(copy);
*result = FALSE; *result = FALSE;
return NULL; return NULL;
@ -146,7 +147,6 @@ parse_args(const char* const inp, int min, int max, gboolean* result)
g_slist_free_full(tokens, free); g_slist_free_full(tokens, free);
gchar** args = malloc((num + 1) * sizeof(*args)); gchar** args = malloc((num + 1) * sizeof(*args));
args[0] = NULL; args[0] = NULL;
g_free(copy);
*result = TRUE; *result = TRUE;
return args; return args;
@ -164,7 +164,6 @@ parse_args(const char* const inp, int min, int max, gboolean* result)
args[arg_count] = NULL; args[arg_count] = NULL;
g_slist_free_full(tokens, free); g_slist_free_full(tokens, free);
g_free(copy);
*result = TRUE; *result = TRUE;
return args; return args;
} }