From 82a33308ef514a4a2982d4da7b7f316476edd080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 13 Oct 2016 18:29:07 +0100 Subject: [PATCH] parser: don't hang if heredoc errors We would tokenize whatever bytes were left, which meant that we could be overwriting tok = EOF with garbage. In this case, with RPAREN for ). In some weird cases like this one, the parser would get confused and loop forever. --- parser/parser_test.go | 4 ++++ parser/tokenizer.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/parser/parser_test.go b/parser/parser_test.go index ca2fddd7c..f216781a8 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -554,6 +554,10 @@ var shellTests = []struct { "< p.buriedHdocs { p.doHeredocs() + if p.tok == token.EOF { + return + } } case '\\': if p.npos < len(p.src)-1 && p.src[p.npos+1] == '\n' {