[pygobject] Fix leaking of boxed array elements



commit b388c3e87ce86d26560337c88eb33d0a95647db8
Author: Martin Pitt <martinpitt gnome org>
Date:   Fri Mar 1 15:01:06 2013 +0100

    Fix leaking of boxed array elements
    
    Commit 631d8ef879a copies struct array elements, but this needlessly duplicates
    and leaks the array element for boxed types. So only do it for plain structs.
    
    This fixes the memory leak with test_gi.TestGValue.test_gvalue_flat_array_out.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693402

 gi/pygi-marshal-to-py.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-marshal-to-py.c b/gi/pygi-marshal-to-py.c
index 693d2ea..6dde41d 100644
--- a/gi/pygi-marshal-to-py.c
+++ b/gi/pygi-marshal-to-py.c
@@ -434,7 +434,8 @@ _pygi_marshal_to_py_array (PyGIInvokeState   *state,
                                 item_arg.v_pointer = g_variant_ref_sink (g_array_index (array_, gpointer, 
i));
                               else
                                 item_arg.v_pointer = g_array_index (array_, gpointer, i);
-                            } else if (arg_cache->transfer == GI_TRANSFER_EVERYTHING && 
!item_arg_cache->is_pointer) {
+                            } else if (arg_cache->transfer == GI_TRANSFER_EVERYTHING && 
!item_arg_cache->is_pointer &&
+                                       !g_type_is_a (iface_cache->g_type, G_TYPE_BOXED)) {
                                 /* array elements are structs */
                                 gpointer *_struct = g_malloc (item_size);
                                 memcpy (_struct, array_->data + i * item_size,


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