mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
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:
commit
9101e23ff6
19 changed files with 151 additions and 25 deletions
|
@ -13569,7 +13569,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
|
|||
"* wants int");
|
||||
goto onError;
|
||||
}
|
||||
width = PyLong_AsLong(v);
|
||||
width = PyLong_AsSsize_t(v);
|
||||
if (width == -1 && PyErr_Occurred())
|
||||
goto onError;
|
||||
if (width < 0) {
|
||||
|
@ -13609,7 +13609,7 @@ PyUnicode_Format(PyObject *format, PyObject *args)
|
|||
"* wants int");
|
||||
goto onError;
|
||||
}
|
||||
prec = PyLong_AsLong(v);
|
||||
prec = _PyLong_AsInt(v);
|
||||
if (prec == -1 && PyErr_Occurred())
|
||||
goto onError;
|
||||
if (prec < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue