[Python-checkins] python/nondist/sandbox/collections dequemodule.c,
1.6, 1.7
rhettinger at projects.sourceforge.net
rhettinger at projects.sourceforge.net
Tue Jan 27 10:57:35 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/collections
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11864
Modified Files:
dequemodule.c
Log Message:
Strengthen error checking
Index: dequemodule.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/collections/dequemodule.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dequemodule.c 27 Jan 2004 15:04:24 -0000 1.6
--- dequemodule.c 27 Jan 2004 15:57:31 -0000 1.7
***************
*** 168,173 ****
--- 168,177 ----
while (deque_len(deque)) {
item = deque_pop(deque, NULL);
+ if (item == NULL)
+ return -1;
Py_DECREF(item);
}
+ assert(deque->leftblock == deque->rightblock &&
+ deque->leftindex > deque->rightindex);
return 0;
}
***************
*** 184,192 ****
static void
! deque_dealloc(dequeobject *deque) // XXX ? any uncomfortable assumptions
{
PyObject_GC_UnTrack(deque);
! deque_clear(deque);
! PyMem_Free(deque->leftblock);
deque->leftblock = NULL;
deque->rightblock = NULL;
--- 188,199 ----
static void
! deque_dealloc(dequeobject *deque)
{
PyObject_GC_UnTrack(deque);
! if (deque->leftblock != NULL) {
! int err = deque_clear(deque);
! assert(err == 0);
! PyMem_Free(deque->leftblock);
! }
deque->leftblock = NULL;
deque->rightblock = NULL;
***************
*** 241,244 ****
--- 248,255 ----
return NULL;
args = PyTuple_Pack(1, seq);
+ if (args == NULL) {
+ Py_DECREF(seq);
+ return NULL;
+ }
result = PyTuple_Pack(2, deque->ob_type, args);
Py_DECREF(seq);
More information about the Python-checkins
mailing list