[gobject-introspection: 3/4] gimarshallingtests: Don't leak properties in destruction



commit 29adf615baa95a0a4cd0cccd5e1b6364b59443ea
Author: Simon Feltman <s feltman gmail com>
Date:   Fri Dec 23 15:19:44 2016 -0800

    gimarshallingtests: Don't leak properties in destruction
    
    Clear strv, boxed_struct, variant, boxed_glist, and object properties
    during destruction. This fixes trivial memory leaks found in the PyGObject
    tests suite.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735013
    Closes #113

 tests/gimarshallingtests.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 4005acae..4465bcb6 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -5371,15 +5371,12 @@ gi_marshalling_tests_properties_object_finalize (GObject *obj)
   GIMarshallingTestsPropertiesObject *self;
   self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (obj);
 
-  if (self->some_strv != NULL) {
-    g_strfreev (self->some_strv);
-    self->some_strv = NULL;
-  }
-
-  if (self->some_gvalue) {
-    g_boxed_free (G_TYPE_VALUE, self->some_gvalue);
-    self->some_gvalue = NULL;
-  }
+  g_clear_pointer (&self->some_strv, g_strfreev);
+  g_clear_pointer (&self->some_boxed_struct, gi_marshalling_tests_boxed_struct_free);
+  g_clear_pointer (&self->some_variant, g_variant_unref);
+  g_clear_pointer (&self->some_boxed_glist, g_list_free);
+  g_clear_pointer (&self->some_gvalue, g_boxed_free);
+  g_clear_object (&self->some_object);
 
   G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
 }


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