summaryrefslogtreecommitdiff
path: root/Modules/_randommodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-07-24 09:02:53 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-07-24 09:02:53 +0300
commit3b77d01dbc9e7cf8e32803a307f2ecf7b2bf0f05 (patch)
treec068f5321f638951218d1d980c0e1d851fb245b1 /Modules/_randommodule.c
parentaffac0062dfdca716f4dc9228476b06a516c032b (diff)
downloadcpython-git-3b77d01dbc9e7cf8e32803a307f2ecf7b2bf0f05.tar.gz
Issue #24620: Random.setstate() now validates the value of state last element.
Diffstat (limited to 'Modules/_randommodule.c')
-rw-r--r--Modules/_randommodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 8bb9e37d16..480df92eed 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -363,6 +363,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);