diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-03-29 16:24:29 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-03-29 16:24:29 (GMT) |
commit | d4814bfa232371d7339e2b3a16e6669fb7828c49 (patch) | |
tree | ccd29cf6a6e027ddf5e0564a4477c28b4a50102c | |
parent | 174e909842837abb5b4337c42d0c0c7cffa0f6c7 (diff) | |
download | cpython-d4814bfa232371d7339e2b3a16e6669fb7828c49.zip cpython-d4814bfa232371d7339e2b3a16e6669fb7828c49.tar.gz cpython-d4814bfa232371d7339e2b3a16e6669fb7828c49.tar.bz2 |
Issue #532631: Apply floatformat changes to unicodeobject.c
as well as stringobject.c.
-rw-r--r-- | Objects/unicodeobject.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 4ce9bed..6edc2f8 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: |