mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.
Will backport.
This commit is contained in:
parent
2a4712dc80
commit
62a21121b4
5 changed files with 37 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue