diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2014-01-13 16:51:41 -0800 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-01-13 16:51:41 -0800 |
commit | 44d003798d9d14dde16fb44c69b94a411bdee26b (patch) | |
tree | 8ffa4ea73b775ec0c7e40d79ecdf963413dbc1a1 | |
parent | 415b240e3baab522f3bf9752995610f950ba609e (diff) | |
download | pygobject-44d003798d9d14dde16fb44c69b94a411bdee26b.tar.gz |
Fix mid-argument list callback user data expecting a tuple3.11.4
Ensure user data arguments are always packed into a tuple during callback
marshaling. This fixes cases where there is mid-argument user data which is
not in the form of a variable length tuple.
https://bugzilla.gnome.org/show_bug.cgi?id=722104
-rw-r--r-- | gi/pygi-marshal-from-py.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c index ed2e5822..41dcf542 100644 --- a/gi/pygi-marshal-from-py.c +++ b/gi/pygi-marshal-from-py.c @@ -1362,8 +1362,19 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState *state, /* NULL out user_data if it was not supplied and the default arg placeholder * was used instead. */ - if (py_user_data == _PyGIDefaultArgPlaceholder) + if (py_user_data == _PyGIDefaultArgPlaceholder) { py_user_data = NULL; + } else if (callable_cache->user_data_varargs_index < 0) { + /* For non-variable length user data, place the user data in a + * single item tuple which is concatenated to the callbacks arguments. + * This allows callback input arg marshaling to always expect a + * tuple for user data. Note the + */ + py_user_data = Py_BuildValue("(O)", py_user_data, NULL); + } else { + /* increment the ref borrowed from PyTuple_GetItem above */ + Py_INCREF (py_user_data); + } } } @@ -1384,6 +1395,9 @@ _pygi_marshal_from_py_interface_callback (PyGIInvokeState *state, closure = _pygi_make_native_closure (callable_info, callback_cache->scope, py_arg, py_user_data); arg->v_pointer = closure->closure; + /* always decref the user data as _pygi_make_native_closure adds its own ref */ + Py_XDECREF (py_user_data); + /* The PyGICClosure instance is used as user data passed into the C function. * The return trip to python will marshal this back and pull the python user data out. */ |