mirror of https://github.com/python/cpython
Issue #15989: Fix possible integer overflow in str formatting as in unicode formatting.
This commit is contained in:
parent
6b78bffa20
commit
926f3a37de
|
@ -4355,7 +4355,9 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
"* wants int");
|
"* wants int");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
width = PyInt_AsLong(v);
|
width = PyInt_AsSsize_t(v);
|
||||||
|
if (width == -1 && PyErr_Occurred())
|
||||||
|
goto error;
|
||||||
if (width < 0) {
|
if (width < 0) {
|
||||||
flags |= F_LJUST;
|
flags |= F_LJUST;
|
||||||
width = -width;
|
width = -width;
|
||||||
|
@ -4392,7 +4394,9 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
"* wants int");
|
"* wants int");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
prec = PyInt_AsLong(v);
|
prec = _PyInt_AsInt(v);
|
||||||
|
if (prec == -1 && PyErr_Occurred())
|
||||||
|
goto error;
|
||||||
if (prec < 0)
|
if (prec < 0)
|
||||||
prec = 0;
|
prec = 0;
|
||||||
if (--fmtcnt >= 0)
|
if (--fmtcnt >= 0)
|
||||||
|
|
Loading…
Reference in New Issue