Allow printing a leading '-' and the maximum number of exponent digits

rather than raising RuntimeError (allocated space is sufficient for the
additional character).
This commit is contained in:
Stefan Krah 2012-04-05 15:46:19 +02:00
parent 0774e9b9f5
commit ff3eca0cc3
2 changed files with 50 additions and 2 deletions

View file

@ -2435,8 +2435,8 @@ dectuple_as_str(PyObject *dectuple)
if (sign_special[1] == '\0') {
/* not a special number */
*cp++ = 'E';
n = snprintf(cp, MPD_EXPDIGITS+1, "%" PRI_mpd_ssize_t, exp);
if (n < 0 || n >= MPD_EXPDIGITS+1) {
n = snprintf(cp, MPD_EXPDIGITS+2, "%" PRI_mpd_ssize_t, exp);
if (n < 0 || n >= MPD_EXPDIGITS+2) {
PyErr_SetString(PyExc_RuntimeError,
"internal error in dec_sequence_as_str");
goto error;