[gnome-todo] todo.txt: fix a memory leak in parser



commit 2cf427f84d04e4c2634ab43c4960838516707c2c
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Sun Apr 9 11:11:15 2017 +0530

    todo.txt: fix a memory leak in parser
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781084

 plugins/todo-txt/gtd-todo-txt-parser.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/plugins/todo-txt/gtd-todo-txt-parser.c b/plugins/todo-txt/gtd-todo-txt-parser.c
index aeedcbc..e017417 100644
--- a/plugins/todo-txt/gtd-todo-txt-parser.c
+++ b/plugins/todo-txt/gtd-todo-txt-parser.c
@@ -399,16 +399,16 @@ GList*
 gtd_todo_txt_parser_tokenize (const gchar *line)
 {
   GList *tokens = NULL;
-  gchar **token = NULL;
+  g_autofree GStrv token = NULL;
+  gsize i;
 
   token = g_strsplit (line, " ", -1);
 
-  while (*token)
-  {
-    g_strstrip (*token);
-    tokens = g_list_prepend (tokens, g_strdup(*token));
-    token++;
-  }
+  for (i = 0; token[i]; i++)
+    {
+      g_strstrip (token[i]);
+      tokens = g_list_prepend (tokens, g_strdup (token[i]));
+    }
 
   tokens = g_list_reverse (tokens);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]