Commit d644cbd0 authored by Simon Feltman's avatar Simon Feltman
Browse files

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
parent 510789d5
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment