Fixed a url history memory leak.
authorDaniel Carl <danielcarl@gmx.de>
Tue, 5 Mar 2013 15:52:16 +0000 (16:52 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Tue, 5 Mar 2013 15:52:16 +0000 (16:52 +0100)
src/completion.c
src/url_history.c

index bb8ee0d..eee21e7 100644 (file)
@@ -78,11 +78,13 @@ gboolean completion_complete(gboolean back)
         vp.comps.completions = completion_init_completion(
             vp.comps.completions, source, (Comp_Func)util_strcasestr, &input[6], ":open "
         );
+        g_list_free(source);
     } else if (!strncmp(input, ":tabopen ", 9)) {
         source = url_history_get_all();
         vp.comps.completions = completion_init_completion(
             vp.comps.completions, source, (Comp_Func)util_strcasestr, &input[9], ":tabopen "
         );
+        g_list_free(source);
     } else {
         source = g_hash_table_get_keys(core.behave.commands);
         source = g_list_sort(source, (GCompareFunc)g_strcmp0);
index 8ae771e..9255208 100644 (file)
@@ -27,6 +27,9 @@ void url_history_init(void)
 
     file_lock_set(fileno(file), F_UNLCK);
     fclose(file);
+
+    /* reverse history form file */
+    core.behave.url_history = g_list_reverse(core.behave.url_history);
 }
 
 void url_history_cleanup(void)
@@ -101,4 +104,5 @@ static void url_history_free(UrlHist* item)
     if (item->title) {
         g_free(item->title);
     }
+    g_free(item);
 }