[epiphany/gnome-3-22] embed-prefs: Fix memory leak when setting languages



commit 6ff985ed09415473871692eaef98266517562136
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Jan 29 21:51:54 2017 -0600

    embed-prefs: Fix memory leak when setting languages
    
    This was a tough one. It's a GArray rather than a GPtrArray, which led
    me on a wild goose chase trying to set a clear function for the array...
    the clear function is not allowed to actually free memory, since GArray
    is not designed for holding pointers.
    
    This code should probably be refactored further.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682723

 embed/ephy-embed-prefs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 1a9b588..6ff1243 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -344,7 +344,7 @@ webkit_pref_callback_accept_languages (GSettings  *settings,
 {
   GArray *array;
   char **languages;
-  int i;
+  guint i;
   EphyEmbedShell *shell = ephy_embed_shell_get_default ();
   WebKitWebContext *web_context = ephy_embed_shell_get_web_context (shell);
 
@@ -372,6 +372,8 @@ webkit_pref_callback_accept_languages (GSettings  *settings,
   }
 
   g_strfreev (languages);
+  for (i = 0; i < array->len; i++)
+    g_free (g_array_index (array, char *, i));
   g_array_free (array, TRUE);
 }
 


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