about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-09-22 23:39:56 +0100
committerJames Booth <boothj5@gmail.com>2013-09-23 00:09:30 +0100
commitcb507497b63c4a7f16792d76f28af967099ceb41 (patch)
treeb2c8f84c2a296b67fb4174c7c2b6474344001030 /src
parente7159aca3030085f0bc6263fbf8586b56c1a512b (diff)
downloadprofani-tty-cb507497b63c4a7f16792d76f28af967099ceb41.tar.gz
Fixed memory leak in parse_args_with_freetext
issue #226
Diffstat (limited to 'src')
-rw-r--r--src/tools/parser.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/parser.c b/src/tools/parser.c
index f273923a..942b17ca 100644
--- a/src/tools/parser.c
+++ b/src/tools/parser.c
@@ -256,6 +256,8 @@ parse_args_with_freetext(const char * const inp, int min, int max)
         }
     }
 
+    free(copy);
+
     if (in_token) {
         tokens = g_slist_append(tokens, g_strndup(token_start, token_size));
     }
@@ -265,7 +267,6 @@ parse_args_with_freetext(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);
         return NULL;
 
     // if min allowed is 0 and 0 found, return empty char* array
@@ -288,7 +289,6 @@ parse_args_with_freetext(const char * const inp, int min, int max)
 
         args[arg_count] = NULL;
         g_slist_free_full(tokens, free);
-        free(copy);
 
         return args;
     }