summaryrefslogtreecommitdiff
path: root/gi/pygi-marshal-cleanup.c
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2013-02-27 23:21:34 +0100
committerMartin Pitt <martinpitt@gnome.org>2013-02-27 23:21:34 +0100
commit4f5e8b7554b6388aa2d0eb4a3b285d99499163be (patch)
treedf959fda79d15b5782d6a5814032d50f3174774e /gi/pygi-marshal-cleanup.c
parent70118c3840b10e1585d066a4be485c097cd23e99 (diff)
downloadpygobject-4f5e8b7554b6388aa2d0eb4a3b285d99499163be.tar.gz
Fix cleanup of GValue arrays
Commit bc1fd8 introduced a thinko: We must not change item_arg_cache->from_py_cleanup, as it's a global cache. Revert the original change, and instead put the hack into _pygi_marshal_cleanup_from_py_array(), which now short-circuits _pygi_marshal_cleanup_from_py_interface_struct_gvalue() to avoid trying to release a slice which has never been allocated in _pygi_marshal_from_py_array(). https://bugzilla.gnome.org/show_bug.cgi?id=672224
Diffstat (limited to 'gi/pygi-marshal-cleanup.c')
-rw-r--r--gi/pygi-marshal-cleanup.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index bd9522a5..50f593db 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -368,8 +368,17 @@ _pygi_marshal_cleanup_from_py_array (PyGIInvokeState *state,
else if (sequence_cache->item_cache->is_pointer)
item = g_array_index (array_, gpointer, i);
/* case 3: C array or GArray with simple types or structs */
- else
+ else {
item = array_->data + i * sequence_cache->item_size;
+ /* special-case hack: GValue array items do not get slice
+ * allocated in _pygi_marshal_from_py_array(), so we must
+ * not try to deallocate it as a slice and thus
+ * short-circuit cleanup_func. */
+ if (cleanup_func == _pygi_marshal_cleanup_from_py_interface_struct_gvalue) {
+ g_value_unset ((GValue*) item);
+ continue;
+ }
+ }
cleanup_func (state, sequence_cache->item_cache, item, TRUE);
}