[grilo-plugins] lua-factory: fix leak from grl_config_get_string()



commit d3e7fedf1d0a55c1c8441af647b13db80cb32395
Author: Victor Toso <me victortoso com>
Date:   Thu Feb 23 21:19:19 2017 +0100

    lua-factory: fix leak from grl_config_get_string()
    
    As it uses g_key_file_get_string() which returns newly allocated.
    
    27 bytes in 1 blocks are definitely lost in loss record 1,825 of 4,702
       at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
       by 0x4E895B8: g_malloc (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x4E7B24A: ??? (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x4E7CA27: g_key_file_get_string (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x53D0514: grl_config_get_string (grl-config.c:278)
       by 0xA0A5BDD: all_mandatory_options_has_value (grl-lua-factory.c:1133)
       by 0xA0A5BDD: grl_lua_factory_source_new (grl-lua-factory.c:467)
       by 0xA0A68CB: grl_lua_factory_plugin_init (grl-lua-factory.c:235)
       by 0x53AD615: grl_plugin_load (grl-plugin.c:243)
       by 0x53AF3BF: activate_plugin (grl-registry.c:483)
       by 0x53B2584: grl_registry_activate_plugin_by_id (grl-registry.c:1382)
       by 0x40206C: test_lua_factory_setup (test_lua_factory_utils.c:60)
       by 0x40193E: test_acoustid_setup (test_lua_acoustid.c:194)
       by 0x40193E: main (test_lua_acoustid.c:200)
    
    27 bytes in 1 blocks are definitely lost in loss record 1,839 of 4,775
       at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
       by 0x4E895B8: g_malloc (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x4E7B24A: ??? (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x4E7CA27: g_key_file_get_string (in /usr/lib64/libglib-2.0.so.0.5000.3)
       by 0x53D0514: grl_config_get_string (grl-config.c:278)
       by 0xA0A5F06: lua_plugin_source_init (grl-lua-factory.c:580)
       by 0xA0A5F06: grl_lua_factory_source_new (grl-lua-factory.c:477)
       by 0xA0A68DB: grl_lua_factory_plugin_init (grl-lua-factory.c:235)
       by 0x53AD615: grl_plugin_load (grl-plugin.c:243)
       by 0x53AF3BF: activate_plugin (grl-registry.c:483)
       by 0x53B2584: grl_registry_activate_plugin_by_id (grl-registry.c:1382)
       by 0x40206C: test_lua_factory_setup (test_lua_factory_utils.c:60)
       by 0x40193E: test_acoustid_setup (test_lua_acoustid.c:194)
       by 0x40193E: main (test_lua_acoustid.c:200)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779444

 src/lua-factory/grl-lua-factory.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-factory.c b/src/lua-factory/grl-lua-factory.c
index 3f14427..8fa7557 100644
--- a/src/lua-factory/grl-lua-factory.c
+++ b/src/lua-factory/grl-lua-factory.c
@@ -559,7 +559,7 @@ lua_plugin_source_init (GrlLuaFactorySource *lua_source)
   GList *it_keys = NULL;
   GList *list_keys = NULL;
   const gchar *key = NULL;
-  const gchar *value = NULL;
+  gchar *value = NULL;
   gboolean ret = FALSE;
 
   /* Source does not have grl_source_init() */
@@ -600,6 +600,7 @@ lua_plugin_source_init (GrlLuaFactorySource *lua_source)
 
           g_free (lua_key);
         }
+        g_free (value);
       }
     }
     g_list_free (list_keys);
@@ -1126,17 +1127,21 @@ all_mandatory_options_has_value (const gchar *source_id,
   list_keys = (source_configs != NULL) ?
               g_hash_table_get_keys (source_configs) : NULL;
   for (it_keys = list_keys; it_keys; it_keys = g_list_next (it_keys)) {
+    gchar *key_value;
+
     key = it_keys->data;
     is_mandatory = g_hash_table_lookup (source_configs, key);
 
+    key_value = grl_config_get_string (merged_configs, key);
     if (g_strcmp0 (is_mandatory, "true") == 0
-        && grl_config_get_string (merged_configs, key) == NULL) {
+        && key_value == NULL) {
 
       GRL_DEBUG ("Source %s is missing config for required key '%s'", source_id, key);
 
       g_list_free (list_keys);
       return FALSE;
     }
+    g_free (key_value);
   }
   g_list_free (list_keys);
   return TRUE;


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