[Xfce4-commits] <midori:master> Don't leak form suggestions and don't return from the loop

Christian Dywan noreply at xfce.org
Wed Oct 7 23:06:01 CEST 2009


Updating branch refs/heads/master
         to 0706bdbbe76273fff6cc5efa9d7800297369ce5e (commit)
       from 37e2c84b2b657200d1b28b72bbda897feec10912 (commit)

commit 0706bdbbe76273fff6cc5efa9d7800297369ce5e
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Oct 7 23:04:30 2009 +0200

    Don't leak form suggestions and don't return from the loop

 extensions/formhistory.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index 5b6de32..67d170a 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -75,20 +75,26 @@ formhistory_prepare_js ()
 static gchar*
 formhistory_build_js ()
 {
-    const gchar* suggestions = "";
+    gchar* suggestions = g_strdup ("");
     GHashTableIter iter;
     gpointer key, value;
+    gchar* script;
+
     g_hash_table_iter_init (&iter, global_keys);
     while (g_hash_table_iter_next (&iter, &key, &value))
-       suggestions = g_strdup_printf ("%s arr[\"%s\"] = [%s]; ",
-                                      suggestions, (char*)key, (char*)value);
-    gchar* script = g_strdup_printf ("function FormSuggestions(eid) { "
-                                     "arr = new Array();"
-                                     "%s"
-                                     "this.suggestions = arr[eid]; }"
-                                     "%s",
-                                     suggestions,
-                                     jsforms);
+    {
+       gchar* _suggestions = g_strdup_printf ("%s arr[\"%s\"] = [%s]; ",
+                                              suggestions, (char*)key, (char*)value);
+       katze_assign (suggestions, _suggestions);
+    }
+    script = g_strdup_printf ("function FormSuggestions(eid) { "
+                              "arr = new Array();"
+                              "%s"
+                              "this.suggestions = arr[eid]; }"
+                              "%s",
+                              suggestions,
+                              jsforms);
+    g_free (suggestions);
    return script;
 }
 
@@ -104,7 +110,7 @@ formhistory_update_main_hash (GHashTable* keys)
     while (g_hash_table_iter_next (&iter, (gpointer)&key, (gpointer)&value))
     {
         if (value && *value && (strlen (value) > MAXCHARS || strlen (value) < MINCHARS))
-            return;
+            continue;
 
         tmp = g_hash_table_lookup (global_keys, (gpointer)key);
         if (tmp)



More information about the Xfce4-commits mailing list