[pygobject] Fix memory leak in _pygi_argument_to_array()



commit 002a834dd993b82508a4fe262269befcf1a6d341
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Mar 4 12:10:03 2013 +0100

    Fix memory leak in _pygi_argument_to_array()
    
    Free the originally allocated GArray data before setting it to our already
    existing C array.
    
    Discovered by test_gi.TestStructure.test_boxed_struct_return test case.

 gi/pygi-argument.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index df2c54d..4cf82d0 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -855,6 +855,7 @@ _pygi_argument_to_array (GIArgument  *arg,
 
             g_array = g_array_new (is_zero_terminated, FALSE, item_size);
 
+            g_free (g_array->data);
             g_array->data = arg->v_pointer;
             g_array->len = length;
             *out_free_array = TRUE;


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