Commit 104a15dd authored by Tim Peters's avatar Tim Peters

_BTree_set(): We leaked a reference to the first key of the second

bucket when deleting the first child of a BTree node with more than one
child.  This caused >600 int objects to leak in the OI and OO flavors
of testRemoveSucceeds.
parent 3fb8f83e
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
****************************************************************************/ ****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.73 2003/04/10 23:36:55 tim_one Exp $\n" #define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.74 2003/04/11 16:09:58 tim_one Exp $\n"
/* Sanity-check a BTree. This is a private helper for BTree_check. Return: /* Sanity-check a BTree. This is a private helper for BTree_check. Return:
* -1 Error. If it's an internal inconsistency in the BTree, * -1 Error. If it's an internal inconsistency in the BTree,
...@@ -757,9 +757,22 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value, ...@@ -757,9 +757,22 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
/* Remove the child from self->data. */ /* Remove the child from self->data. */
Py_DECREF(d->child); Py_DECREF(d->child);
#ifdef KEY_TYPE_IS_PYOBJECT
if (min) { if (min) {
DECREF_KEY(d->key); DECREF_KEY(d->key);
} }
else if (self->len > 1) {
/* We're deleting the first child of a BTree with more than one
* child. The key at d+1 is about to be shifted into slot 0,
* and hence never to be referenced again (the key in slot 0 is
* trash).
*/
DECREF_KEY((d+1)->key);
}
/* Else min==0 and len==1: we're emptying the BTree entirely, and
* there is no key in need of decrefing.
*/
#endif
--self->len; --self->len;
if (min < self->len) if (min < self->len)
memmove(d, d+1, (self->len - min) * sizeof(BTreeItem)); memmove(d, d+1, (self->len - min) * sizeof(BTreeItem));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment