Commit ec683139 authored by Tim Peters's avatar Tim Peters

nextBTreeItems() and nextTreeSetItems(): unlike the other set iteration

"next" functions, these can return a PER_USE() error *after* decrefing
the keys and values left over from the last call.  But they don't mark
the iteration as terminated, so finiSetIteration() will also try to
decref the leftovers.  The fix is to mark the iteration as terminated
when these functions fail.
parent f6a898f9
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
****************************************************************************/ ****************************************************************************/
#define BTREEITEMSTEMPLATE_C "$Id: BTreeItemsTemplate.c,v 1.11 2002/06/09 19:27:48 tim_one Exp $\n" #define BTREEITEMSTEMPLATE_C "$Id: BTreeItemsTemplate.c,v 1.12 2002/06/09 22:22:50 tim_one Exp $\n"
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
...@@ -514,8 +514,14 @@ nextBTreeItems(SetIteration *i) ...@@ -514,8 +514,14 @@ nextBTreeItems(SetIteration *i)
Bucket *currentbucket; Bucket *currentbucket;
currentbucket = BUCKET(ITEMS(i->set)->currentbucket); currentbucket = BUCKET(ITEMS(i->set)->currentbucket);
UNLESS(PER_USE(currentbucket))
UNLESS(PER_USE(currentbucket)) return -1; {
/* Mark iteration terminated, so that finiSetIteration doesn't
* try to redundantly decref the key and value
*/
i->position = -1;
return -1;
}
COPY_KEY(i->key, currentbucket->keys[ITEMS(i->set)->currentoffset]); COPY_KEY(i->key, currentbucket->keys[ITEMS(i->set)->currentoffset]);
INCREF_KEY(i->key); INCREF_KEY(i->key);
...@@ -555,8 +561,14 @@ nextTreeSetItems(SetIteration *i) ...@@ -555,8 +561,14 @@ nextTreeSetItems(SetIteration *i)
Bucket *currentbucket; Bucket *currentbucket;
currentbucket = BUCKET(ITEMS(i->set)->currentbucket); currentbucket = BUCKET(ITEMS(i->set)->currentbucket);
UNLESS(PER_USE(currentbucket))
UNLESS(PER_USE(currentbucket)) return -1; {
/* Mark iteration terminated, so that finiSetIteration doesn't
* try to redundantly decref the key and value
*/
i->position = -1;
return -1;
}
COPY_KEY(i->key, currentbucket->keys[ITEMS(i->set)->currentoffset]); COPY_KEY(i->key, currentbucket->keys[ITEMS(i->set)->currentoffset]);
INCREF_KEY(i->key); INCREF_KEY(i->key);
......
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