Fix #130: update ineffassign: fix crash on break/continue outside of loop

This commit is contained in:
Denis Isaev 2018-08-08 23:54:46 +03:00 committed by Isaev Denis
parent b900926bfc
commit 0262f00bfb
2 changed files with 8 additions and 2 deletions

4
Gopkg.lock generated
View File

@ -157,11 +157,11 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:55b1295e893690bce0d5952101bf21b3ce28a32bd3625007104068b76646e842" digest = "1:3a5ea92f78579dfd319260ce995575c07890c8aff429035637287a00da664647"
name = "github.com/golangci/ineffassign" name = "github.com/golangci/ineffassign"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "7b41b0f84881918dab3c16c5e5148d8aa55d27b4" revision = "2ee8f2867dde308c46d401d6d30f6c644094b167"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -505,6 +505,12 @@ func (s *branchStack) get(lbl *ast.Ident) *branch {
return br return br
} }
} }
// Guard against invalid code (break/continue outside of loop).
if lbl == nil {
return &branch{}
}
return s.push(lbl.Obj) return s.push(lbl.Obj)
} }