diff options
author | Kirill Smelkov <kirr@landau.phys.spbu.ru> | 2010-10-02 17:43:50 +0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-10-07 15:18:29 +1030 |
commit | 5f2bb5c83a6171db1a7e107d4385d080a2ca6ec2 (patch) | |
tree | bfcb79658138cbb8a9544af3583ecdb6fce829d5 | |
parent | 30219892d05cede96bd2a478f582e4c550bba44a (diff) | |
download | samba-5f2bb5c83a6171db1a7e107d4385d080a2ca6ec2.tar.gz samba-5f2bb5c83a6171db1a7e107d4385d080a2ca6ec2.tar.xz samba-5f2bb5c83a6171db1a7e107d4385d080a2ca6ec2.zip |
pytdb: Check errors after PyObject_New() calls
The call could fail with e.g. MemoryError, and we'll dereference NULL
pointer without checking.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
(This used to be ctdb commit 09369aa86e233a58ed131fa5b7584b6c86527d40)
-rw-r--r-- | ctdb/lib/tdb/pytdb.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ctdb/lib/tdb/pytdb.c b/ctdb/lib/tdb/pytdb.c index 402fa5d9d3..009063359f 100644 --- a/ctdb/lib/tdb/pytdb.c +++ b/ctdb/lib/tdb/pytdb.c @@ -97,6 +97,11 @@ static PyObject *py_tdb_open(PyTypeObject *type, PyObject *args, PyObject *kwarg } ret = PyObject_New(PyTdbObject, &PyTdb); + if (!ret) { + tdb_close(ctx); + return NULL; + } + ret->ctx = ctx; ret->closed = false; return (PyObject *)ret; @@ -330,6 +335,8 @@ static PyObject *tdb_object_iter(PyTdbObject *self) PyTdbIteratorObject *ret; ret = PyObject_New(PyTdbIteratorObject, &PyTdbIterator); + if (!ret) + return NULL; ret->current = tdb_firstkey(self->ctx); ret->iteratee = self; Py_INCREF(self); |