[grilo-plugins] dmap: Fix memory leak when Avahi is absent



commit 21e65f906bd3725c4222192e59b6128d8f526c86
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 22 14:53:27 2013 +0100

    dmap: Fix memory leak when Avahi is absent
    
    When Avahi isn't around, the plugin init will fail, and leak
    a couple of hash tables and objects. Clean those up before
    exiting the function.
    
    This also checks for error properly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=715016

 src/dmap/grl-dmap.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/dmap/grl-dmap.c b/src/dmap/grl-dmap.c
index 07d2374..54c6ddc 100644
--- a/src/dmap/grl-dmap.c
+++ b/src/dmap/grl-dmap.c
@@ -142,11 +142,15 @@ grl_dmap_plugin_init (GrlRegistry *registry,
                     G_CALLBACK (service_removed_cb),
                     (gpointer) plugin);
 
-  dmap_mdns_browser_start (browser, &error);
-  if (error) {
+  if (!dmap_mdns_browser_start (browser, &error)) {
     g_warning ("error starting browser. code: %d message: %s",
                error->code,
                error->message);
+    g_error_free (error);
+
+    g_clear_pointer (&connections, g_hash_table_unref);
+    g_clear_pointer (&sources, g_hash_table_unref);
+    g_clear_object (&browser);
     return FALSE;
   }
 


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