[grilo] core: Close module if it won't be used



commit af2bfe599af3e3e0886c69c40974df8ca9ce3433
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Fri Jul 16 17:56:27 2010 +0200

    core: Close module if it won't be used
    
    Close the module if something fails after opening it, so it is not leaking
    memory.

 src/grl-plugin-registry.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/src/grl-plugin-registry.c b/src/grl-plugin-registry.c
index 06664d5..08b50c7 100644
--- a/src/grl-plugin-registry.c
+++ b/src/grl-plugin-registry.c
@@ -413,12 +413,14 @@ grl_plugin_registry_load (GrlPluginRegistry *registry, const gchar *path)
 
   if (!g_module_symbol (module, "GRL_PLUGIN_DESCRIPTOR", (gpointer) &plugin)) {
     g_warning ("Did not find plugin descriptor: '%s'", path);
+    g_module_close (module);
     return FALSE;
   }
 
   if (!plugin->plugin_init ||
       !plugin->info.id) {
     g_warning ("Plugin descriptor is not valid: '%s'", path);
+    g_module_close (module);
     return FALSE;
   }
 
@@ -443,6 +445,7 @@ grl_plugin_registry_load (GrlPluginRegistry *registry, const gchar *path)
   if (!plugin->plugin_init (registry, &plugin->info, plugin_configs)) {
     g_hash_table_remove (registry->priv->plugins, plugin->info.id);
     g_warning ("Failed to initialize plugin: '%s'", path);
+    g_module_close (module);
     return FALSE;
   }
 



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