Skip to content

Commit 80f2fb8

Browse files
authored
Add bounds check for array access (#44)
1 parent 06d5fe6 commit 80f2fb8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

parser.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,12 @@ func parseArrayAccess(item celast.Expr) string {
811811
return ""
812812
}
813813
args := item.AsCall().Args()
814+
if len(args) < 2 {
815+
return ""
816+
}
817+
if args[1].Kind() != celast.LiteralKind {
818+
return ""
819+
}
814820
return fmt.Sprintf("%s[%v]", walkSelect(args[0]), args[1].AsLiteral().Value())
815821
}
816822

0 commit comments

Comments
 (0)