diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-18 11:58:06 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-18 11:58:50 +0200 |
commit | a6bfa95939caad2fbaa70506c8124be29ba91f36 (patch) | |
tree | 28725c67f428151d4e3821f803b7a6db8aa332cc | |
parent | 9db0321d31f9add44dd916db39bb642d028905e6 (diff) | |
download | pygobject-a6bfa95939caad2fbaa70506c8124be29ba91f36.tar.gz |
pygobject_init: fix a small leak
-rw-r--r-- | gi/pygobject.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gi/pygobject.h b/gi/pygobject.h index 37624292..d2425152 100644 --- a/gi/pygobject.h +++ b/gi/pygobject.h @@ -343,11 +343,13 @@ pygobject_init(int req_major, int req_minor, int req_micro) } cobject = PyObject_GetAttrString(gobject, "_PyGObject_API"); - if (cobject && PyCapsule_CheckExact(cobject)) + if (cobject && PyCapsule_CheckExact(cobject)) { _PyGObject_API = (struct _PyGObject_Functions *) PyCapsule_GetPointer(cobject, "gobject._PyGObject_API"); - else { + Py_DECREF (cobject); + } else { PyErr_SetString(PyExc_ImportError, "could not import gobject (could not find _PyGObject_API object)"); + Py_XDECREF (cobject); Py_DECREF(gobject); return NULL; } |