[Python-checkins] r76298 - python/branches/py3k/Objects/rangeobject.c
mark.dickinson
python-checkins at python.org
Sun Nov 15 13:56:08 CET 2009
Author: mark.dickinson
Date: Sun Nov 15 13:56:08 2009
New Revision: 76298
Log:
Fix another case of potential signed overflow.
Modified:
python/branches/py3k/Objects/rangeobject.c
Modified: python/branches/py3k/Objects/rangeobject.c
==============================================================================
--- python/branches/py3k/Objects/rangeobject.c (original)
+++ python/branches/py3k/Objects/rangeobject.c Sun Nov 15 13:56:08 2009
@@ -411,7 +411,10 @@
rangeiter_next(rangeiterobject *r)
{
if (r->index < r->len)
- return PyLong_FromLong(r->start + (r->index++) * r->step);
+ /* cast to unsigned to avoid possible signed overflow
+ in intermediate calculations. */
+ return PyLong_FromLong((long)(r->start +
+ (unsigned long)(r->index++) * r->step));
return NULL;
}
More information about the Python-checkins
mailing list