[Python-checkins]
python/dist/src/Modules collectionsmodule.c, 1.26, 1.27
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Fri Oct 1 04:01:08 CEST 2004
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18895/Modules
Modified Files:
collectionsmodule.c
Log Message:
deque_traverse(): If the deque had one block, and its rightindex was
BLOCKLEN-1, this assert-failed in a debug build, or went wild with a
NULL pointer in a release build. Reported on c.l.py by Stefan Behnel.
Index: collectionsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- collectionsmodule.c 1 Oct 2004 01:35:54 -0000 1.26
+++ collectionsmodule.c 1 Oct 2004 02:01:04 -0000 1.27
@@ -478,19 +478,22 @@
static int
deque_traverse(dequeobject *deque, visitproc visit, void *arg)
{
- block * b = deque->leftblock;
- int index = deque->leftindex;
+ block *b;
PyObject *item;
+ int index;
+ int indexlo = deque->leftindex;
- while (b != deque->rightblock || index <= deque->rightindex) {
- item = b->data[index];
- index++;
- if (index == BLOCKLEN ) {
- assert(b->rightlink != NULL);
- b = b->rightlink;
- index = 0;
+ assert(deque->leftblock != NULL);
+ for (b = deque->leftblock; b != NULL; b = b->rightlink) {
+ const int indexhi = b == deque->rightblock ?
+ deque->rightindex :
+ BLOCKLEN - 1;
+
+ for (index = indexlo; index <= indexhi; ++index) {
+ item = b->data[index];
+ Py_VISIT(item);
}
- Py_VISIT(item);
+ indexlo = 0;
}
return 0;
}
More information about the Python-checkins
mailing list