diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-08-16 04:40:14 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-08-16 04:40:14 (GMT) |
commit | 432ea4ff375f920fa4a469d34e5dad56fb33f915 (patch) | |
tree | 909cb271045d26b32b535a53199f0f50d79d776f /Modules | |
parent | 5e4aafa258fa85d1aebf469ddf8f5d43b7671c38 (diff) | |
download | cpython-432ea4ff375f920fa4a469d34e5dad56fb33f915.zip cpython-432ea4ff375f920fa4a469d34e5dad56fb33f915.tar.gz cpython-432ea4ff375f920fa4a469d34e5dad56fb33f915.tar.bz2 |
fail when negative values are passed to instr()
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index a8735f2..501ec91 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1456,6 +1456,10 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) case 1: if (!PyArg_ParseTuple(args,"i;n", &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative"); + return NULL; + } rtn2 = winnstr(self->win, rtn, Py_MIN(n, 1023)); break; case 2: @@ -1466,6 +1470,10 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) case 3: if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative"); + return NULL; + } rtn2 = mvwinnstr(self->win, y, x, rtn, Py_MIN(n,1023)); break; default: |