Skip to content

Commit 75506e8

Browse files
committed
Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
Patch by Robin Schreiber.
1 parent 07795df commit 75506e8

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Misc/ACKS

+1
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ Ralf Schmitt
848848
Michael Schneider
849849
Peter Schneider-Kamp
850850
Arvin Schnell
851+
Robin Schreiber
851852
Chad J. Schroeder
852853
Sam Schulenburg
853854
Stefan Schwarzer

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
14+
Patch by Robin Schreiber.
15+
1316
- Issue #15604: Update uses of PyObject_IsTrue() to check for and handle
1417
errors correctly. Patch by Serhiy Storchaka.
1518

Python/pystate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ PyState_FindModule(struct PyModuleDef* m)
248248
return NULL;
249249
if (state->modules_by_index == NULL)
250250
return NULL;
251-
if (index > PyList_GET_SIZE(state->modules_by_index))
251+
if (index >= PyList_GET_SIZE(state->modules_by_index))
252252
return NULL;
253253
res = PyList_GET_ITEM(state->modules_by_index, index);
254254
return res==Py_None ? NULL : res;

0 commit comments

Comments
 (0)