gplugin/gplugin

Fix leak of gplugin_plugin_get_filename results.
develop/asan
2019-01-31, Elliott Sales de Andrade
08abb4bde2d4
Parents dfc5a2328fce
Children 3418e24e0842
Fix leak of gplugin_plugin_get_filename results.

It's not a const char. The change from hash insert to hash replace is so that
the pointer of the new key stays valid for the rest of that block.
--- a/gplugin/gplugin-manager.c Thu Jan 31 22:06:35 2019 -0500
+++ b/gplugin/gplugin-manager.c Thu Jan 31 22:12:25 2019 -0500
@@ -477,9 +477,9 @@
}
/* now insert into our view */
- g_hash_table_insert(manager->plugins_filename_view,
- real_filename,
- g_object_ref(G_OBJECT(plugin)));
+ g_hash_table_replace(manager->plugins_filename_view,
+ real_filename,
+ g_object_ref(G_OBJECT(plugin)));
/* Grab the list of plugins with our id and prepend the new
* plugin to it before updating it.
@@ -487,10 +487,12 @@
l = g_hash_table_lookup(manager->plugins, id);
for(ll = l; ll; ll = ll->next) {
GPluginPlugin *splugin = GPLUGIN_PLUGIN(ll->data);
- const gchar *sfilename = gplugin_plugin_get_filename(splugin);
+ gchar *sfilename = gplugin_plugin_get_filename(splugin);
if(!g_strcmp0(real_filename, sfilename))
seen = TRUE;
+
+ g_free(sfilename);
}
if(!seen) {
l = g_slist_prepend(l, g_object_ref(plugin));
@@ -1064,7 +1066,7 @@
* a value of the plugin itself.
*/
manager->plugins_filename_view =
- g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref);
+ g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
/* The loaders hash table is keyed on the supported extensions of the
* loader. Which means that a loader that supports multiple extensions