summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Hiscocks <steven@hiscocks.me.uk>2013-02-17 14:27:59 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-02-22 16:57:44 +0100
commit6d0c634ca32c772c72b0bb4207866e2a35f4eadb (patch)
tree27e699ae9a8baf7f54fc77eb7db0d698c380fb41 /src
parentc71f26eba57a8263dc28c99f9f446e0a75307f34 (diff)
systemd-python: fix memory leak in _reader and minor bugs
iternext now checks for error from get_next, and changed a DECREF to XDECREF rather than NULL check
Diffstat (limited to 'src')
-rw-r--r--src/python-systemd/_reader.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index 70676aceca..b754014e9b 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -326,8 +326,7 @@ Journal_seek(Journal *self, PyObject *args, PyObject *keywds)
PyErr_SetString(PyExc_ValueError, "Invalid value for whence");
}
- if (result)
- Py_DECREF(result);
+ Py_XDECREF(result);
if (PyErr_Occurred())
return NULL;
Py_RETURN_NONE;
@@ -498,6 +497,8 @@ Journal_iternext(PyObject *self)
Py_ssize_t dict_size;
dict = PyObject_CallMethod(self, "get_next", "");
+ if (PyErr_Occurred())
+ return NULL;
dict_size = PyDict_Size(dict);
if ((int64_t) dict_size > 0LL) {
return dict;