Issue #15989: Fix several occurrences of integer overflow

when result of PyLong_AsLong() narrowed to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
This commit is contained in:
Serhiy Storchaka 2013-01-19 12:26:26 +02:00
parent ff12fae80e
commit 441d30fac7
16 changed files with 129 additions and 20 deletions

View file

@ -240,7 +240,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
return -1;
}
fd = PyLong_AsLong(nameobj);
fd = _PyLong_AsInt(nameobj);
if (fd < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,