]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
heck environment closed status before closing a cursors. Fixes #763928.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 15 Jul 2003 19:12:54 +0000 (19:12 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 15 Jul 2003 19:12:54 +0000 (19:12 +0000)
Modules/_bsddb.c

index 227fe7bdf58672d4a77a802907d467548137e6d1..990c89f215bd170e3a369e71a07012482a606afc 100644 (file)
@@ -774,7 +774,14 @@ DBCursor_dealloc(DBCursorObject* self)
     int err;
     if (self->dbc != NULL) {
         MYDB_BEGIN_ALLOW_THREADS;
-       if (self->mydb->db != NULL)
+       /* If the underlying database has been closed, we don't
+          need to do anything. If the environment has been closed
+          we need to leak, as BerkeleyDB will crash trying to access
+          the environment. There was an exception when the 
+          user closed the environment even though there still was
+          a database open. */
+       if (self->mydb->db && self->mydb->myenvobj &&
+           !self->mydb->myenvobj->closed)
             err = self->dbc->c_close(self->dbc);
         self->dbc = NULL;
         MYDB_END_ALLOW_THREADS;