Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35c38ea

Browse files
committed
heck environment closed status before closing a cursors. Fixes #763928.
1 parent f393fc6 commit 35c38ea

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Modules/_bsddb.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,14 @@ DBCursor_dealloc(DBCursorObject* self)
774774
int err;
775775
if (self->dbc != NULL) {
776776
MYDB_BEGIN_ALLOW_THREADS;
777-
if (self->mydb->db != NULL)
777+
/* If the underlying database has been closed, we don't
778+
need to do anything. If the environment has been closed
779+
we need to leak, as BerkeleyDB will crash trying to access
780+
the environment. There was an exception when the
781+
user closed the environment even though there still was
782+
a database open. */
783+
if (self->mydb->db && self->mydb->myenvobj &&
784+
!self->mydb->myenvobj->closed)
778785
err = self->dbc->c_close(self->dbc);
779786
self->dbc = NULL;
780787
MYDB_END_ALLOW_THREADS;

0 commit comments

Comments
 (0)