mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
fail when negative values are passed to instr()
This commit is contained in:
parent
5e4aafa258
commit
432ea4ff37
3 changed files with 12 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue