diff options
author | Alberto Mardegan <mardy@users.sourceforge.net> | 2012-01-23 12:37:26 +0200 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2012-01-24 15:55:25 +0100 |
commit | d69e5b3c7bdb9113382fd125c256b12bff4c24d2 (patch) | |
tree | d70914ce88a13743a45b6595604dce44d8ede137 | |
parent | 77f32d9110bfeb6dad8457f565b4c70b5998fef6 (diff) | |
download | pygobject-d69e5b3c7bdb9113382fd125c256b12bff4c24d2.tar.gz |
Respect transfer-type when demarshalling GErrors
The marshaller previously ignored "transfer full" on GError* arguments, causing
crashes due to double-freeing them. This causes the testCallbackUserdata() test
case to crash after the previous GError/GHashTable marshalling fix.
https://bugzilla.gnome.org/show_bug.cgi?id=666270
-rw-r--r-- | gi/pygi-argument.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index bf2ed8a6..9d99c352 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -1785,7 +1785,16 @@ _pygi_argument_to_object (GIArgument *arg, break; } case GI_TYPE_TAG_ERROR: - if (pyglib_error_check ( (GError **) &arg->v_pointer)) { + { + GError *error = (GError *) arg->v_pointer; + if (error != NULL && transfer == GI_TRANSFER_NOTHING) { + /* If we have not been transferred the ownership we must copy + * the error, because pyglib_error_check() is going to free it. + */ + error = g_error_copy (error); + } + + if (pyglib_error_check (&error)) { PyObject *err_type; PyObject *err_value; PyObject *err_trace; @@ -1798,6 +1807,7 @@ _pygi_argument_to_object (GIArgument *arg, Py_INCREF (object); break; } + } } return object; |