From 5aa96895d8d5d2c76d75842a5e3c79ef4f09d895 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sun, 13 Aug 2006 18:11:43 +0000 Subject: [PATCH] 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 b39e6f2884b..6fef6c2e65e 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -1797,7 +1797,6 @@ DB_join(DBObject* self, PyObject* args) DBC** cursors; DBC* dbc; - if (!PyArg_ParseTuple(args,"O|i:join", &cursorsObj, &flags)) return NULL; @@ -1811,6 +1810,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