[epiphany] embed-prefs: Fix memory leak when setting languages



commit 6bae3a12e3544f05947c96b5ca61577016bfa558
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 d59420a..dcdddee 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -348,7 +348,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);
 
@@ -380,6 +380,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]