summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2013-10-03 19:25:34 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2013-10-03 19:25:34 -0700
commitd644cbd0c0ad85142286754838db848c4eb1707f (patch)
tree4acad698fbfa88402b39d393dda595f0dd111f56
parent510789d52e9e2fd863d26613f3282364eb175601 (diff)
downloadpygobject-d644cbd0c0ad85142286754838db848c4eb1707f.tar.gz
Fix memory leak for caller allocated GValue out arguments
Swizzle the order of type checks in _cleanup_caller_allocates so G_TYPE_VALUE arguments are checked before G_TYPE_BOXED. The ordering is important because G_TYPE_VALUE is a sub-type of boxed and so its specialized cleanup code was never being called (g_value_unset). Additionally update check to use g_type_is_a instead of a compare to handle the potential case of a G_TYPE_VALUE sub-type. https://bugzilla.gnome.org/show_bug.cgi?id=709397
-rw-r--r--gi/pygi-marshal-cleanup.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index 57ded65f..a877306f 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -29,16 +29,17 @@ _cleanup_caller_allocates (PyGIInvokeState *state,
{
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)cache;
- if (g_type_is_a (iface_cache->g_type, G_TYPE_BOXED)) {
+ /* check GValue first because GValue is also a boxed sub-type */
+ if (g_type_is_a (iface_cache->g_type, G_TYPE_VALUE)) {
+ if (was_processed)
+ g_value_unset (data);
+ g_slice_free (GValue, data);
+ } else if (g_type_is_a (iface_cache->g_type, G_TYPE_BOXED)) {
gsize size;
if (was_processed)
return; /* will be cleaned up at deallocation */
size = g_struct_info_get_size (iface_cache->interface_info);
g_slice_free1 (size, data);
- } else if (iface_cache->g_type == G_TYPE_VALUE) {
- if (was_processed)
- g_value_unset (data);
- g_slice_free (GValue, data);
} else if (iface_cache->is_foreign) {
if (was_processed)
return; /* will be cleaned up at deallocation */