[Python-checkins] r52143 - python/branches/release24-maint/Modules/_bsddb.c
andrew.kuchling
python-checkins at python.org
Wed Oct 4 15:14:48 CEST 2006
Author: andrew.kuchling
Date: Wed Oct 4 15:14:48 2006
New Revision: 52143
Modified:
python/branches/release24-maint/Modules/_bsddb.c
Log:
[Backport r51251 | neal.norwitz]
Handle malloc and fopen failures more gracefully.
Klocwork 180-181
Modified: python/branches/release24-maint/Modules/_bsddb.c
==============================================================================
--- python/branches/release24-maint/Modules/_bsddb.c (original)
+++ python/branches/release24-maint/Modules/_bsddb.c Wed Oct 4 15:14:48 2006
@@ -1693,7 +1693,6 @@
DBC** cursors;
DBC* dbc;
-
if (!PyArg_ParseTuple(args,"O|i:join", &cursorsObj, &flags))
return NULL;
@@ -1707,6 +1706,11 @@
length = PyObject_Length(cursorsObj);
cursors = malloc((length+1) * sizeof(DBC*));
+ if (!cursors) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
cursors[length] = NULL;
for (x=0; x<length; x++) {
PyObject* item = PySequence_GetItem(cursorsObj, x);
@@ -2367,11 +2371,13 @@
CHECK_DB_NOT_CLOSED(self);
if (outFileName)
outFile = fopen(outFileName, "w");
+ /* XXX(nnorwitz): it should probably be an exception if outFile
+ can't be opened. */
MYDB_BEGIN_ALLOW_THREADS;
err = self->db->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
More information about the Python-checkins
mailing list