Skip to content

Commit

Permalink
Fix possibility of rare crash during dealloc. Fixes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
KIMURA Chikahiro authored and jamadden committed Sep 15, 2017
1 parent 9e6e910 commit 16e70dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion BTrees/BTreeTemplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2277,8 +2277,10 @@ BTree_init(PyObject *self, PyObject *args, PyObject *kwds)
static void
BTree_dealloc(BTree *self)
{
if (self->state != cPersistent_GHOST_STATE)
PyObject_GC_UnTrack((PyObject *)self);
if (self->state != cPersistent_GHOST_STATE) {
_BTree_clear(self);
}
cPersistenceCAPI->pertype->tp_dealloc((PyObject *)self);
}

Expand Down
4 changes: 3 additions & 1 deletion BTrees/BucketTemplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,8 +1708,10 @@ Bucket_init(PyObject *self, PyObject *args, PyObject *kwds)
static void
bucket_dealloc(Bucket *self)
{
if (self->state != cPersistent_GHOST_STATE)
PyObject_GC_UnTrack((PyObject *)self);
if (self->state != cPersistent_GHOST_STATE) {
_bucket_clear(self);
}

cPersistenceCAPI->pertype->tp_dealloc((PyObject *)self);
}
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
BTrees is used but the ``persistent`` C extension is not available.
Previously this could result in an odd ``AttributeError``. See
https://github.com/zopefoundation/BTrees/pull/55
- Fix the possibility of a rare crash in the C extension when
deallocating items. See https://github.com/zopefoundation/BTrees/issues/75


4.4.1 (2017-01-24)
------------------
Expand Down

0 comments on commit 16e70dd

Please sign in to comment.