Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 20 Aug 2012 17:30:46 +0000 (19:30 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 20 Aug 2012 17:30:46 +0000 (19:30 +0200)
Patch by Robin Schreiber.

Misc/ACKS
Misc/NEWS
Python/pystate.c

index 2e72f22592cd9dbad4d5f92c13648058a1320627..0d851df31344e4763dfc2bae10ccf2cadd4e7693 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -848,6 +848,7 @@ Ralf Schmitt
 Michael Schneider
 Peter Schneider-Kamp
 Arvin Schnell
+Robin Schreiber
 Chad J. Schroeder
 Sam Schulenburg
 Stefan Schwarzer
index 857a161536c8118bbdb80c5910f6f12efd110110..74c168f1c539f1d8180163ec0b182b06f4422b7e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
 Core and Builtins
 -----------------
 
+- Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
+  Patch by Robin Schreiber.
+
 - Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
   errors correctly.  Patch by Serhiy Storchaka.
 
index 31b5423d38e44d6ad4cfc019d7f945a65aa06ee5..13923313c0a258a5ff558ee2c3c9cf685fc3a493 100644 (file)
@@ -248,7 +248,7 @@ PyState_FindModule(struct PyModuleDef* m)
         return NULL;
     if (state->modules_by_index == NULL)
         return NULL;
-    if (index > PyList_GET_SIZE(state->modules_by_index))
+    if (index >= PyList_GET_SIZE(state->modules_by_index))
         return NULL;
     res = PyList_GET_ITEM(state->modules_by_index, index);
     return res==Py_None ? NULL : res;