summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-01-25 05:29:17 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-01-25 05:29:17 (GMT)
commitebf1dcaeaf04fc28b322ca641caee752ea5e633e (patch)
tree43102c85b43a1d0deeca762b7fcda4033f69034d /Modules
parent88f669a757402eb7cb513ef80ea1137089f810ac (diff)
downloadcpython-ebf1dcaeaf04fc28b322ca641caee752ea5e633e.zip
cpython-ebf1dcaeaf04fc28b322ca641caee752ea5e633e.tar.gz
cpython-ebf1dcaeaf04fc28b322ca641caee752ea5e633e.tar.bz2
Backport:
Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_bsddb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 0ef797c..c6efa1c 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -265,6 +265,7 @@ typedef struct {
typedef struct {
PyObject_HEAD
DB_TXN* txn;
+ PyObject *env;
#ifdef HAVE_WEAKREF
PyObject *in_weakreflist; /* List of weak references */
#endif
@@ -921,6 +922,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
@@ -931,11 +934,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;
@@ -966,6 +968,7 @@ DBTxn_dealloc(DBTxnObject* self)
}
#endif
+ Py_DECREF(self->env);
PyObject_Del(self);
}