diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_randommodule.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 4377ee0..416e266 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -340,6 +340,10 @@ random_setstate(RandomObject *self, PyObject *state) index = PyLong_AsLong(PyTuple_GET_ITEM(state, i)); if (index == -1 && PyErr_Occurred()) return NULL; + if (index < 0 || index > N) { + PyErr_SetString(PyExc_ValueError, "invalid state"); + return NULL; + } self->index = (int)index; Py_INCREF(Py_None); |