[libdazzle] ring: release remaining data when finalizing



commit 8acb93dab6c7d32fca6c966f622db0c693a442cd
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 27 20:37:26 2018 -0700

    ring: release remaining data when finalizing
    
    If we are find data to release during our final unref, we should free
    it using our destroy callback.
    
    This fixes test-ring under ASAN.

 src/util/dzl-ring.c | 3 +++
 tests/test-ring.c   | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/util/dzl-ring.c b/src/util/dzl-ring.c
index 1ac1350..9a731cd 100644
--- a/src/util/dzl-ring.c
+++ b/src/util/dzl-ring.c
@@ -162,6 +162,9 @@ dzl_ring_destroy (DzlRing *ring)
   g_return_if_fail (ring != NULL);
   g_return_if_fail (ring_impl->ref_count == 0);
 
+  if (ring_impl->destroy != NULL)
+    dzl_ring_foreach (ring, (GFunc)ring_impl->destroy, NULL);
+
   g_free (ring_impl->data);
 
   g_slice_free (DzlRingImpl, ring_impl);
diff --git a/tests/test-ring.c b/tests/test-ring.c
index 3745893..4d469a1 100644
--- a/tests/test-ring.c
+++ b/tests/test-ring.c
@@ -162,9 +162,9 @@ static void
 test_DzlRing_with_array (void)
 {
   DzlRing *ring;
-  GArray *ar0;
-  GArray *ar1;
-  GArray *ar2;
+  GArray *ar0 = NULL;
+  GArray *ar1 = NULL;
+  GArray *ar2 = NULL;
   gpointer tmp;
 
   ring = dzl_ring_sized_new (sizeof (GArray*), 2, test_DzlRing_with_array_cb);


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