Patch #1673759: add a missing overflow check when formatting floats

with %G.
This commit is contained in:
Georg Brandl 2007-07-12 08:38:00 +00:00
parent bc5fbd9f8c
commit 7c3b50db66
4 changed files with 24 additions and 5 deletions

View file

@ -7294,7 +7294,8 @@ formatfloat(Py_UNICODE *buf,
always given), therefore increase the length by one.
*/
if ((type == 'g' && buflen <= (size_t)10 + (size_t)prec) ||
if (((type == 'g' || type == 'G') &&
buflen <= (size_t)10 + (size_t)prec) ||
(type == 'f' && buflen <= (size_t)53 + (size_t)prec)) {
PyErr_SetString(PyExc_OverflowError,
"formatted float is too long (precision too large?)");