From 3184f24de6b2b997f4ba951267f98a7cfc7cdc1b Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Wed, 4 Oct 2006 13:14:48 +0000 Subject: [Backport r51251 | neal.norwitz] Handle malloc and fopen failures more gracefully. Klocwork 180-181 --- Modules/_bsddb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index b2d4ef6..ab0eb29 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -1693,7 +1693,6 @@ DB_join(DBObject* self, PyObject* args) DBC** cursors; DBC* dbc; - if (!PyArg_ParseTuple(args,"O|i:join", &cursorsObj, &flags)) return NULL; @@ -1707,6 +1706,11 @@ DB_join(DBObject* self, PyObject* args) length = PyObject_Length(cursorsObj); cursors = malloc((length+1) * sizeof(DBC*)); + if (!cursors) { + PyErr_NoMemory(); + return NULL; + } + cursors[length] = NULL; for (x=0; xdb->verify(self->db, fileName, dbName, outFile, flags); MYDB_END_ALLOW_THREADS; - if (outFileName) + if (outFile) fclose(outFile); /* DB.verify acts as a DB handle destructor (like close); this was -- cgit v0.12