diff --git a/changelog/potuz_fix_linter.md b/changelog/potuz_fix_linter.md new file mode 100644 index 000000000000..7aff422bd8fe --- /dev/null +++ b/changelog/potuz_fix_linter.md @@ -0,0 +1,3 @@ +### Fixed + +- Fix array out of bounds in static analyzer. diff --git a/tools/analyzers/recursivelock/analyzer.go b/tools/analyzers/recursivelock/analyzer.go index 7dca9dc1b2db..ac110f8cbf4d 100644 --- a/tools/analyzers/recursivelock/analyzer.go +++ b/tools/analyzers/recursivelock/analyzer.go @@ -525,6 +525,9 @@ func hasNestedlock(fullRLockSelector *selIdentList, goPos token.Pos, compareMap if node == (*ast.FuncDecl)(nil) { return "" } else if castedNode, ok := node.(*ast.FuncDecl); ok && castedNode.Recv != nil { + if len(castedNode.Recv.List) == 0 || len(castedNode.Recv.List[0].Names) == 0 { + return "" + } recv = castedNode.Recv.List[0].Names[0] rLockSelector.changeRoot(recv, pass.TypesInfo.ObjectOf(recv)) }