diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-08-15 12:51:20 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-08-15 12:59:36 -0400 |
commit | 31f49d022aee9bbb356e52e5483f182d7ffa8d2f (patch) | |
tree | 0e6e929435a744fff3269cad25be59660a62041c /src/python-systemd/_reader.c | |
parent | c2748ce28c7111037f312c5446335f5538e673e8 (diff) |
systemd-python: check for oom, give nicer error messages
Diffstat (limited to 'src/python-systemd/_reader.c')
-rw-r--r-- | src/python-systemd/_reader.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c index 3b1003ba71..bc5db19049 100644 --- a/src/python-systemd/_reader.c +++ b/src/python-systemd/_reader.c @@ -75,7 +75,7 @@ static int strv_converter(PyObject* obj, void *_result) { assert(result); if (!obj) - goto cleanup; + return 0; if (obj == Py_None) { *result = NULL; @@ -87,6 +87,10 @@ static int strv_converter(PyObject* obj, void *_result) { len = PySequence_Length(obj); *result = new0(char*, len + 1); + if (!*result) { + set_error(-ENOMEM, NULL, NULL); + return 0; + } for (i = 0; i < len; i++) { PyObject *item; @@ -154,7 +158,7 @@ static int Reader_init(Reader *self, PyObject *args, PyObject *keywds) char **files = NULL; static const char* const kwlist[] = {"flags", "path", "files", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "|izO&", (char**) kwlist, + if (!PyArg_ParseTupleAndKeywords(args, keywds, "|izO&:__init__", (char**) kwlist, &flags, &path, strv_converter, &files)) return -1; |