summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index f15e7cd..4def537 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8847,6 +8847,15 @@ formatfloat(Py_UNICODE *buf,
return -1;
if (prec < 0)
prec = 6;
+ /* make sure that the decimal representation of precision really does
+ need at most 10 digits: platforms with sizeof(int) == 8 exist! */
+ if (prec > 0x7fffffffL) {
+ PyErr_SetString(PyExc_OverflowError,
+ "outrageously large precision "
+ "for formatted float");
+ return -1;
+ }
+
if (type == 'f' && fabs(x) >= 1e50)
type = 'g';
/* Worst case length calc to ensure no buffer overrun: