• Rob Pike's avatar
    time: allow long fractions in ParseDuration · 3cca0692
    Rob Pike authored
    The code scanned for an integer after a decimal point, which
    meant things could overflow if the number was very precise
    (0.1234123412341234123412342134s). This fix changes the
    parser to stop adding precision once we run out of bits, rather
    than trigger an erroneous overflow.
    
    We could parse durations using floating-point arithmetic,
    but since the type is int64 and float64 has only has 53 bits
    of precision, that would be imprecise.
    
    Fixes #15011.
    
    Change-Id: If85e22b8f6cef12475e221169bb8f493bb9eb590
    Reviewed-on: https://go-review.googlesource.com/29338Reviewed-by: 's avatarCostin Chirvasuta <costinc@gmail.com>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    3cca0692
format.go 37.2 KB