[pygobject] Don't leak when marshalling GErrors to C



commit 4b9dc03d0e49e9a1f4bf0f2df503bdff00d13a2b
Author: Will Thompson <will thompson collabora co uk>
Date:   Mon Jan 23 13:56:02 2012 +0000

    Don't leak when marshalling GErrors to C
    
    Python-land GLib.GErrors are supposed to have three attributes:
    "message", "domain" and "code". If those attributes are missing, or they
    have the wrong types, the C GError is filled in with a message
    describing the error. The present-but-ill-typed code paths did not
    DECREF the ill-typed values.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=666098

 gi/_glib/pyglib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/gi/_glib/pyglib.c b/gi/_glib/pyglib.c
index 5172aaa..a3d2ec3 100644
--- a/gi/_glib/pyglib.c
+++ b/gi/_glib/pyglib.c
@@ -363,6 +363,7 @@ pyglib_gerror_exception_check(GError **error)
     py_message = PyObject_GetAttrString(value, "message");
     if (!py_message || !PYGLIB_PyUnicode_Check(py_message)) {
         bad_gerror_message = "gi._glib.GError instances must have a 'message' string attribute";
+        Py_XDECREF(py_message);
         goto bad_gerror;
     }
 
@@ -370,6 +371,7 @@ pyglib_gerror_exception_check(GError **error)
     if (!py_domain || !PYGLIB_PyUnicode_Check(py_domain)) {
         bad_gerror_message = "gi._glib.GError instances must have a 'domain' string attribute";
         Py_DECREF(py_message);
+        Py_XDECREF(py_domain);
         goto bad_gerror;
     }
 
@@ -378,6 +380,7 @@ pyglib_gerror_exception_check(GError **error)
         bad_gerror_message = "gi._glib.GError instances must have a 'code' int attribute";
         Py_DECREF(py_message);
         Py_DECREF(py_domain);
+        Py_XDECREF(py_code);
         goto bad_gerror;
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]