[pygobject] Make valgrind happy again



commit 0f2a09d7eae63abb71723b7cd8fb290dcba33426
Author: Tomeu Vizoso <tomeu vizoso collabora co uk>
Date:   Fri Jun 25 13:49:04 2010 +0200

    Make valgrind happy again
    
    * gi/pygi-argument.c, gi/pygi-info.c: Zero two GArgument instances.
    * gi/pygi-invoke.c: workaround bgo#622711 and zero invocation_state.

 gi/pygi-argument.c |    1 +
 gi/pygi-info.c     |    2 ++
 gi/pygi-invoke.c   |    8 ++++++--
 3 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 9533805..7437175 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -643,6 +643,7 @@ _pygi_argument_from_object (PyObject   *object,
     GArgument arg;
     GITypeTag type_tag;
 
+    memset(&arg, 0, sizeof(GArgument));
     type_tag = g_type_info_get_tag (type_info);
 
     switch (type_tag) {
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index fc15187..3d23271 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -1128,6 +1128,8 @@ _wrap_g_field_info_get_value (PyGIBaseInfo *self,
     GArgument value;
     PyObject *py_value = NULL;
 
+    memset(&value, 0, sizeof(GArgument));
+
     if (!PyArg_ParseTuple (args, "O:FieldInfo.get_value", &instance)) {
         return NULL;
     }
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 13ebe80..214d500 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -351,7 +351,11 @@ _prepare_invocation_state (struct invocation_state *state,
                         state->out_args[out_args_pos].v_pointer = NULL;
                         state->args[i] = &state->out_args[out_args_pos];
 
-                        size = g_struct_info_get_size ( (GIStructInfo *) info);
+                        /* FIXME: Remove when bgo#622711 is fixed */
+                        if (g_registered_type_info_get_g_type (info) == G_TYPE_VALUE)
+                            size = sizeof (GValue);
+                        else
+                            size = g_struct_info_get_size ( (GIStructInfo *) info);
 
                         state->args[i]->v_pointer = g_malloc0 (size);
                     } else {
@@ -979,7 +983,7 @@ _free_invocation_state (struct invocation_state *state)
 PyObject *
 _wrap_g_function_info_invoke (PyGIBaseInfo *self, PyObject *py_args)
 {
-    struct invocation_state state;
+    struct invocation_state state = { 0, };
 
     _initialize_invocation_state (&state, self->info, py_args);
 



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