diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-24 09:02:53 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-24 09:02:53 +0300 |
commit | ccfb28ab3462eaca81996ef65d150e76b47a96a2 (patch) | |
tree | 789d3310846d0126b6d96cb0b1ea690e9776a669 /Modules | |
parent | 56a88bc06836d5263ec0b689605ec7a97a8c6316 (diff) | |
download | cpython-ccfb28ab3462eaca81996ef65d150e76b47a96a2.tar.gz |
Issue #24620: Random.setstate() now validates the value of state last element.
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 4377ee0cf4..416e266f0b 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); |