Index: Python/pystrtod.c =================================================================== --- Python/pystrtod.c (revision 59545) +++ Python/pystrtod.c (working copy) @@ -238,6 +238,30 @@ } } + /* Ensure that the exponent is at least 3 digits, + providing the buffer is large enough for the extra zeros. */ + p = buffer; + while (*p && *p != 'e' && *p != 'E') + ++p; + if (*p && (*(p + 1) == '-' || *(p + 1) == '+')) { + char *start = p + 2; + int exponent_digit_count = 0; + int zeros = 0; + p += 2; + while (*p && isdigit((unsigned char)*p)) { + ++p; + ++exponent_digit_count; + } + zeros = 3 - exponent_digit_count; + if (exponent_digit_count && zeros > 0 && + start + zeros + exponent_digit_count + 1 + < buffer + buf_len) { + p = start; + memmove(p + zeros, p, exponent_digit_count + 1); + memset(p, '0', zeros); + } + } + return buffer; }