Issue #24620: Random.setstate() now validates the value of state last element.

This commit is contained in:
Serhiy Storchaka 2015-07-24 09:05:59 +03:00
commit c19bb3279c
3 changed files with 11 additions and 0 deletions

View file

@ -335,6 +335,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);