summaryrefslogtreecommitdiff
path: root/lib/tdb
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@landau.phys.spbu.ru>2010-10-02 17:43:50 +0400
committerJelmer Vernooij <jelmer@samba.org>2010-10-02 22:53:27 +0200
commitab37c48e57a16f69c6b926dbed6d4c1a50bb3fb9 (patch)
tree4a264cd560d584735ab27c8a3a8c8711e8c2147e /lib/tdb
parentbdd6bef5dd839ca6fb2d610b84098d2026bb6db1 (diff)
downloadsamba-ab37c48e57a16f69c6b926dbed6d4c1a50bb3fb9.tar.gz
samba-ab37c48e57a16f69c6b926dbed6d4c1a50bb3fb9.tar.bz2
samba-ab37c48e57a16f69c6b926dbed6d4c1a50bb3fb9.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>
Diffstat (limited to 'lib/tdb')
-rw-r--r--lib/tdb/pytdb.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 402fa5d9d3..009063359f 100644
--- a/lib/tdb/pytdb.c
+++ b/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);