mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Issue #24620: Random.setstate() now validates the value of state last element.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user