Fixed some memory leaks

This commit is contained in:
James Booth
2012-11-26 02:20:44 +00:00
parent b2f9e1ad5f
commit c9ed583412
6 changed files with 38 additions and 4 deletions

View File

@@ -92,13 +92,15 @@ parse_args(const char * const inp, int min, int max)
// if num args not valid return NULL
if ((num < min) || (num > max)) {
g_slist_free_full(tokens, free);
free(copy);
g_free(copy);
return NULL;
// if min allowed is 0 and 0 found, return empty char* array
} else if (min == 0 && num == 0) {
g_slist_free_full(tokens, free);
gchar **args = malloc((num + 1) * sizeof(*args));
args[0] = NULL;
g_free(copy);
return args;
// otherwise return args array
@@ -115,7 +117,7 @@ parse_args(const char * const inp, int min, int max)
args[arg_count] = NULL;
g_slist_free_full(tokens, free);
free(copy);
g_free(copy);
return args;
}