Closed
Description
Bug report
There are multiple cases where PyList_SetItem
does not check for -1
in termios
module. We need to fix this. There are two options to fix this:
< 0
checkPyList_SET_ITEM
usage
There are two possible errors that PyList_SetItem
can produce:
if (!PyList_Check(op)) {
Py_XDECREF(newitem);
PyErr_BadInternalCall();
return -1;
}
if (!valid_index(i, Py_SIZE(op))) {
Py_XDECREF(newitem);
PyErr_SetString(PyExc_IndexError,
"list assignment index out of range");
return -1;
}
Each case needs an explanation.
Lines 116 to 124 in 8c07137
Here cc
is always a list
and i
goes from 0
to some other int
value by i++
, it is safe to use PyList_SET_ITEM
.
Lines 129 to 137 in 8c07137
Here cc
is a list, but VMIN
and VTIME
are 3rd party constants from termios.h
. I guess it is safer to use explicit error check.
Lines 140 to 153 in 8c07137
Here we need to check for possibel PyLong_FromLong
error, but we can use PyList_SET_ITEM
.