[Python-checkins] cpython (2.7): Issue #23985: Fixed integer overflow in iterator object. Original patch by

serhiy.storchaka python-checkins at python.org
Thu May 21 19:52:26 CEST 2015


https://hg.python.org/cpython/rev/274c1b0a2494
changeset:   96188:274c1b0a2494
branch:      2.7
parent:      96172:cbe28273fd8d
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Thu May 21 20:49:34 2015 +0300
summary:
  Issue #23985: Fixed integer overflow in iterator object.  Original patch by
Clement Rouault.

files:
  Misc/ACKS            |  1 +
  Misc/NEWS            |  3 +++
  Objects/iterobject.c |  5 +++++
  3 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1159,6 +1159,7 @@
 Just van Rossum
 Hugo van Rossum
 Saskia van Rossum
+Clement Rouault
 Donald Wallace Rouse II
 Liam Routt
 Todd Rovito
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #23985: Fixed integer overflow in iterator object.  Original patch by
+  Clement Rouault.
+
 - Issue #24102: Fixed exception type checking in standard error handlers.
 
 Library
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -54,6 +54,11 @@
     seq = it->it_seq;
     if (seq == NULL)
         return NULL;
+    if (it->it_index == LONG_MAX) {
+        PyErr_SetString(PyExc_OverflowError,
+                        "iter index too large");
+        return NULL;
+    }
 
     result = PySequence_GetItem(seq, it->it_index);
     if (result != NULL) {

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list