summaryrefslogtreecommitdiffstats
path: root/Modules/_bsddb.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2003-01-17 08:42:50 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2003-01-17 08:42:50 (GMT)
commitb6c9f780741711750c326418a7b4578543b2aa65 (patch)
tree3d1138e3f04763a5c00b2f7af53c63e58a4f9195 /Modules/_bsddb.c
parentaa71f5f2b4a295065fe3c96889e7ff902991ec07 (diff)
downloadcpython-b6c9f780741711750c326418a7b4578543b2aa65.zip
cpython-b6c9f780741711750c326418a7b4578543b2aa65.tar.gz
cpython-b6c9f780741711750c326418a7b4578543b2aa65.tar.bz2
bugfix: do not double-close DB cursor during deallocation when the
underlying DB has already been closed (and thus all of its cursors). This fixes a potential segfault. SF pybsddb bug id 667343 bugfix: close the DB object when raising an exception due to an error during DB.open. This prevents an exception when closing the environment about not all databases being closed. SF pybsddb bug id 667340
Diffstat (limited to 'Modules/_bsddb.c')
-rw-r--r--Modules/_bsddb.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 9561d28..396a3cc 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -746,7 +746,8 @@ DBCursor_dealloc(DBCursorObject* self)
int err;
if (self->dbc != NULL) {
MYDB_BEGIN_ALLOW_THREADS;
- err = self->dbc->c_close(self->dbc);
+ if (self->mydb->db != NULL)
+ err = self->dbc->c_close(self->dbc);
self->dbc = NULL;
MYDB_END_ALLOW_THREADS;
}
@@ -1623,6 +1624,7 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs)
#endif
MYDB_END_ALLOW_THREADS;
if (makeDBError(err)) {
+ self->db->close(self->db, 0);
self->db = NULL;
return NULL;
}