[pygobject] Respect transfer-type when demarshalling GErrors
- From: Tomeu Vizoso <tomeuv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Respect transfer-type when demarshalling GErrors
- Date: Tue, 24 Jan 2012 15:11:07 +0000 (UTC)
commit d69e5b3c7bdb9113382fd125c256b12bff4c24d2
Author: Alberto Mardegan <mardy users sourceforge net>
Date: Mon Jan 23 12:37:26 2012 +0200
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
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 bf2ed8a..9d99c35 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]