diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-08-15 21:40:14 -0700 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-08-15 21:40:14 -0700 |
commit | 505989c0e701b105bb67b8b4c55681b0328171fe (patch) | |
tree | f931b4fce79fde8043222e9bf5f324fe4d4d107d /Modules/_cursesmodule.c | |
parent | b97001ef46e599642affde61e31abace71486703 (diff) | |
download | cpython-git-505989c0e701b105bb67b8b4c55681b0328171fe.tar.gz |
fail when negative values are passed to instr()
Diffstat (limited to 'Modules/_cursesmodule.c')
-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 d0d747986d..e478a57948 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1095,6 +1095,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,MIN(n,1023)); break; case 2: @@ -1105,6 +1109,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, MIN(n,1023)); break; default: |