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

with %G.
 (backport from rev. 56298)
This commit is contained in:
Georg Brandl 2007-07-12 08:38:04 +00:00
parent fea72f7c10
commit c5db923994
4 changed files with 24 additions and 5 deletions

View file

@ -7290,7 +7290,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?)");