summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <s.feltman@gmail.com>2016-12-23 15:17:52 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2018-07-27 20:46:40 -0400
commit07144de1b8a5e47061324f5fc2166daad4c9c94f (patch)
tree62b771df48c8d472e31a0a72edc3c22aeed757ad
parented8579029430cb64e107f5bbc846f44da5d3a2ec (diff)
downloadgobject-introspection-07144de1b8a5e47061324f5fc2166daad4c9c94f.tar.gz
regress: Don't leak in property setter and destructor
Clear the string property of RegressTestObj prior to setting within the property setter. Make sure the linked list, hash table, and string properties are cleared during destruction. This fixes trivial memory leaks found with the PyGObject test suite. https://bugzilla.gnome.org/show_bug.cgi?id=735013 Closes #113
-rw-r--r--tests/scanner/regress.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 3ab85644..29652caa 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -2153,6 +2153,7 @@ regress_test_obj_set_property (GObject *object,
break;
case PROP_TEST_OBJ_STRING:
+ g_clear_pointer (&self->string, g_free);
self->string = g_value_dup_string (value);
break;
@@ -2250,6 +2251,15 @@ regress_test_obj_dispose (GObject *gobject)
self->boxed = NULL;
}
+ if (self->list)
+ {
+ g_list_free_full (self->list, g_free);
+ self->list = NULL;
+ }
+
+ g_clear_pointer (&self->hash_table, g_hash_table_unref);
+ g_clear_pointer (&self->string, g_free);
+
/* Chain up to the parent class */
G_OBJECT_CLASS (regress_test_obj_parent_class)->dispose (gobject);
}