diff options
author | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2013-06-02 15:39:47 +0200 |
---|---|---|
committer | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2013-06-02 15:39:47 +0200 |
commit | 4d3fb4a98fdec8c04abd2516f9836ed41bc7eeb9 (patch) | |
tree | 3efa1c1c8027998a912ddaaa133fefae2a6b736b /src/cmd/fix | |
parent | 89a1330ec64fed47ccee9c7939dfe5418e30ffee (diff) | |
download | go-4d3fb4a98fdec8c04abd2516f9836ed41bc7eeb9.tar.gz |
cmd/fix: check type assertion in netipv6zone rule.
Fixes issue 5461.
R=golang-dev, r
CC=golang-dev
https://codereview.appspot.com/9947043
Diffstat (limited to 'src/cmd/fix')
-rw-r--r-- | src/cmd/fix/netipv6zone.go | 2 | ||||
-rw-r--r-- | src/cmd/fix/netipv6zone_test.go | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/fix/netipv6zone.go b/src/cmd/fix/netipv6zone.go index fe973a211..195c21807 100644 --- a/src/cmd/fix/netipv6zone.go +++ b/src/cmd/fix/netipv6zone.go @@ -51,7 +51,7 @@ func netipv6zone(f *ast.File) bool { Value: e, } case 1: - if e.(*ast.BasicLit).Value == "0" { + if elit, ok := e.(*ast.BasicLit); ok && elit.Value == "0" { cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...) } else { cl.Elts[i] = &ast.KeyValueExpr{ diff --git a/src/cmd/fix/netipv6zone_test.go b/src/cmd/fix/netipv6zone_test.go index 0fab00531..142880a12 100644 --- a/src/cmd/fix/netipv6zone_test.go +++ b/src/cmd/fix/netipv6zone_test.go @@ -20,6 +20,8 @@ func f() net.Addr { sub(&net.UDPAddr{ip2, 12345}) c := &net.TCPAddr{IP: ip3, Port: 54321} d := &net.TCPAddr{ip4, 0} + p := 1234 + e := &net.TCPAddr{ip4, p} return &net.TCPAddr{ip5}, nil } `, @@ -32,6 +34,8 @@ func f() net.Addr { sub(&net.UDPAddr{IP: ip2, Port: 12345}) c := &net.TCPAddr{IP: ip3, Port: 54321} d := &net.TCPAddr{IP: ip4} + p := 1234 + e := &net.TCPAddr{IP: ip4, Port: p} return &net.TCPAddr{IP: ip5}, nil } `, |