[gom] gom: Fix memory leak when destroying adapter



commit 69aa26b4482f53a3bc91298b66c9cf5a13003948
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Apr 17 00:29:54 2014 +0200

    gom: Fix memory leak when destroying adapter
    
    If we closed the DB properly, we were leaking the queue and thread.

 gom/gom-adapter.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gom/gom-adapter.c b/gom/gom-adapter.c
index 3741b5a..c0d8b3e 100644
--- a/gom/gom-adapter.c
+++ b/gom/gom-adapter.c
@@ -483,13 +483,11 @@ gom_adapter_finalize (GObject *object)
 {
    GomAdapterPrivate *priv = GOM_ADAPTER(object)->priv;
 
-
-   if (priv->db) {
+   if (priv->db)
       g_warning("Adapter not closed, leaking!");
-   } else {
-      g_async_queue_unref(priv->queue);
-      g_thread_unref(priv->thread);
-   }
+
+   g_clear_pointer(&priv->queue, g_async_queue_unref);
+   g_clear_pointer(&priv->thread, g_thread_unref);
 
    G_OBJECT_CLASS(gom_adapter_parent_class)->finalize(object);
 }


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