From d4814bfa232371d7339e2b3a16e6669fb7828c49 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 29 Mar 2009 16:24:29 +0000 Subject: [PATCH] Issue #532631: Apply floatformat changes to unicodeobject.c as well as stringobject.c. --- Objects/unicodeobject.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 4ce9bed1894..6edc2f8347c 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8286,6 +8286,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: