mirror of
https://github.com/golang/go
synced 2024-11-15 04:50:31 -07:00
[release-branch.go1] fmt: fix crash of %b on huge negative int64
««« backport 344d5c33331a fmt: fix crash of %b on huge negative int64 The buffer had 64 bytes but needs one more for the sign. Fixes #3510. R=golang-dev, dave, dsymonds CC=golang-dev https://golang.org/cl/6011057 »»»
This commit is contained in:
parent
bde649ca89
commit
18a71beb07
@ -461,6 +461,9 @@ var fmttests = []struct {
|
|||||||
// zero reflect.Value, which formats as <nil>.
|
// zero reflect.Value, which formats as <nil>.
|
||||||
// This test is just to check that it shows the two NaNs at all.
|
// This test is just to check that it shows the two NaNs at all.
|
||||||
{"%v", map[float64]int{math.NaN(): 1, math.NaN(): 2}, "map[NaN:<nil> NaN:<nil>]"},
|
{"%v", map[float64]int{math.NaN(): 1, math.NaN(): 2}, "map[NaN:<nil> NaN:<nil>]"},
|
||||||
|
|
||||||
|
// Used to crash because nByte didn't allow for a sign.
|
||||||
|
{"%b", int64(-1 << 63), "-1000000000000000000000000000000000000000000000000000000000000000"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSprintf(t *testing.T) {
|
func TestSprintf(t *testing.T) {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
nByte = 64
|
nByte = 65 // %b of an int64, plus a sign.
|
||||||
|
|
||||||
ldigits = "0123456789abcdef"
|
ldigits = "0123456789abcdef"
|
||||||
udigits = "0123456789ABCDEF"
|
udigits = "0123456789ABCDEF"
|
||||||
|
Loading…
Reference in New Issue
Block a user