diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-02-03 07:20:53 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-02-03 07:20:53 (GMT) |
commit | eeed5b7c220c5ef9ec1666d062cb8c4ab0203415 (patch) | |
tree | edcf54e4ab3da15ba2f559445ef516002eb884cc /Modules | |
parent | 94dcf0ddbf4bb4b03ea80fe237dbc37796bb3eee (diff) | |
download | cpython-eeed5b7c220c5ef9ec1666d062cb8c4ab0203415.zip cpython-eeed5b7c220c5ef9ec1666d062cb8c4ab0203415.tar.gz cpython-eeed5b7c220c5ef9ec1666d062cb8c4ab0203415.tar.bz2 |
Merge this fix from the pybsddb tree:
r293 | jcea | 2008-01-31 01:08:19 -0800 (Thu, 31 Jan 2008) | 4 lines
Solved memory leak when using cursors with
databases without environment.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_bsddb.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index f407434..7d05b24 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -824,7 +824,6 @@ DBCursor_dealloc(DBCursorObject* self) } if (self->dbc != NULL) { - MYDB_BEGIN_ALLOW_THREADS; /* 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 @@ -833,9 +832,14 @@ DBCursor_dealloc(DBCursorObject* self) a database open. */ if (self->mydb->db && self->mydb->myenvobj && !self->mydb->myenvobj->closed) + /* test for: open db + no environment or non-closed environment */ + if (self->mydb->db && (!self->mydb->myenvobj || (self->mydb->myenvobj && + !self->mydb->myenvobj->closed))) { + MYDB_BEGIN_ALLOW_THREADS; err = self->dbc->c_close(self->dbc); + MYDB_END_ALLOW_THREADS; + } self->dbc = NULL; - MYDB_END_ALLOW_THREADS; } Py_XDECREF( self->mydb ); PyObject_Del(self); |