diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-01-25 05:21:55 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-01-25 05:21:55 (GMT) |
commit | 62a21121b4acf9b37ea62e64498a869048fefb5b (patch) | |
tree | 282bdbc5fc5c4f9edc9f94a0c0288dd3764aa7a0 /Modules/_bsddb.c | |
parent | 2a4712dc80bcc873bea2238fcc855c9b92b82095 (diff) | |
download | cpython-62a21121b4acf9b37ea62e64498a869048fefb5b.zip cpython-62a21121b4acf9b37ea62e64498a869048fefb5b.tar.gz cpython-62a21121b4acf9b37ea62e64498a869048fefb5b.tar.bz2 |
Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.
Will backport.
Diffstat (limited to 'Modules/_bsddb.c')
-rw-r--r-- | Modules/_bsddb.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index ef161a9..1687d01 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -266,6 +266,7 @@ typedef struct { typedef struct { PyObject_HEAD DB_TXN* txn; + PyObject *env; #ifdef HAVE_WEAKREF PyObject *in_weakreflist; /* List of weak references */ #endif @@ -928,6 +929,8 @@ newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags) DBTxnObject* self = PyObject_New(DBTxnObject, &DBTxn_Type); if (self == NULL) return NULL; + Py_INCREF(myenv); + self->env = (PyObject*)myenv; #ifdef HAVE_WEAKREF self->in_weakreflist = NULL; #endif @@ -938,11 +941,10 @@ newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags) #else err = txn_begin(myenv->db_env, parent, &(self->txn), flags); #endif - /* TODO add a weakref(self) to the self->myenvobj->open_child_weakrefs - * list so that a DBEnv can refuse to close without aborting any open - * open DBTxns and closing any open DBs first. */ MYDB_END_ALLOW_THREADS; if (makeDBError(err)) { + Py_DECREF(self->env); + PyObject_Del(self); self = NULL; } return self; @@ -973,6 +975,7 @@ DBTxn_dealloc(DBTxnObject* self) } #endif + Py_DECREF(self->env); PyObject_Del(self); } |