Patch #1673759: add a missing overflow check when formatting floats
with %G.
(backport from rev. 56298)
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index cee78a0..5d343bd 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4188,7 +4188,8 @@
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?)");