[pygobject] Fix double-freeing GValues in arrays
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix double-freeing GValues in arrays
- Date: Fri, 16 Mar 2012 12:46:06 +0000 (UTC)
commit bc1fd8814df6c1e85b586d0fb943c89f7e2b78b5
Author: Martin Pitt <martin pitt ubuntu com>
Date: Fri Mar 16 13:27:56 2012 +0100
Fix double-freeing GValues in arrays
When marshalling a GValue array to C, the GValue items are copied into a C
GValue array, not a C GValue pointer array. _pygi_marshal_from_py_array()
already calls the cleanup_func for the original item;
_pygi_marshal_cleanup_from_py_array() must not do it again, as this would try
to g_slice_free the array item.
https://bugzilla.gnome.org/show_bug.cgi?id=672224
gi/pygi-marshal-from-py.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index 92cd499..962747f 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -847,8 +847,13 @@ _pygi_marshal_from_py_array (PyGIInvokeState *state,
g_value_copy ((GValue*) item.v_pointer, dest);
}
- if (from_py_cleanup)
+ if (from_py_cleanup) {
from_py_cleanup (state, item_arg_cache, item.v_pointer, TRUE);
+ /* we freed the original copy already, the new one is a
+ * struct in an array. _pygi_marshal_cleanup_from_py_array()
+ * must not free it again */
+ item_arg_cache->from_py_cleanup = NULL;
+ }
} else if (!is_boxed) {
memcpy (array_->data + (i * item_size), item.v_pointer, item_size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]