mirror of
https://github.com/python/cpython.git
synced 2026-01-05 06:52:26 +00:00
Issue #24620: Random.setstate() now validates the value of state last element.
This commit is contained in:
commit
c19bb3279c
3 changed files with 11 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue