comparison Python/pystate.c @ 78678:7789111afe05

Issue #15726: Fix incorrect bounds checking in PyState_FindModule. Patch by Robin Schreiber.
author Antoine Pitrou <solipsis@pitrou.net>
date Mon, 20 Aug 2012 19:31:52 +0200
parents 55e8cba34b11 b96a4b1e7ecb
children 5aa1bc2f00ad 6bcaba9e8df2
comparison
equal deleted inserted replaced
78675:0a3149b30f20 78678:7789111afe05
246 PyObject *res; 246 PyObject *res;
247 if (index == 0) 247 if (index == 0)
248 return NULL; 248 return NULL;
249 if (state->modules_by_index == NULL) 249 if (state->modules_by_index == NULL)
250 return NULL; 250 return NULL;
251 if (index > PyList_GET_SIZE(state->modules_by_index)) 251 if (index >= PyList_GET_SIZE(state->modules_by_index))
252 return NULL; 252 return NULL;
253 res = PyList_GET_ITEM(state->modules_by_index, index); 253 res = PyList_GET_ITEM(state->modules_by_index, index);
254 return res==Py_None ? NULL : res; 254 return res==Py_None ? NULL : res;
255 } 255 }
256 256