From 07cb4267298610bff32a9bc39dcfbd85cfaf35e6 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Sat, 31 Oct 2015 15:11:53 +0300 Subject: [PATCH] parser: fix panicing for # style comments HCL supports # style comments, which are 1 size len. We assumed that it's always // or /* , which are two size length --- parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/parser.go b/parser/parser.go index 9b5e2c9..bd51411 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -78,7 +78,7 @@ func (p *Parser) consumeComment() (comment *ast.Comment, endline int) { endline = p.tok.Pos.Line // count the endline if it's multiline comment, ie starting with /* - if p.tok.Text[1] == '*' { + if len(p.tok.Text) > 1 && p.tok.Text[1] == '*' { // don't use range here - no need to decode Unicode code points for i := 0; i < len(p.tok.Text); i++ { if p.tok.Text[i] == '\n' {