From: Neal Norwitz Date: Sun, 13 Aug 2006 18:11:43 +0000 (+0000) Subject: Handle malloc and fopen failures more gracefully. X-Git-Tag: v2.5c1~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5aa96895d8d5d2c76d75842a5e3c79ef4f09d895;p=python Handle malloc and fopen failures more gracefully. Klocwork 180-181 --- diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index b39e6f2884..6fef6c2e65 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