From: Daniel Carl <danielcarl@gmx.de>
Date: Tue, 5 Mar 2013 15:52:16 +0000 (+0100)
Subject: Fixed a url history memory leak.
X-Git-Url: https://git.owens.tech/assets/dummy.html/assets/dummy.html/git?a=commitdiff_plain;h=794ddadb3a49f77f78009253e6bd87054452c528;p=vimb.git

Fixed a url history memory leak.
---

diff --git a/src/completion.c b/src/completion.c
index bb8ee0d..eee21e7 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -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);
diff --git a/src/url_history.c b/src/url_history.c
index 8ae771e..9255208 100644
--- a/src/url_history.c
+++ b/src/url_history.c
@@ -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);
 }