From e76bff9291b86a8f5b2a7c002736b615024bc3cb Mon Sep 17 00:00:00 2001 From: James Westman Date: Mon, 18 Apr 2022 17:05:07 -0500 Subject: [PATCH] Fix crash in parser The Until parse node would return True if it reached EOF, which was not correct and could cause other parse nodes to run past the end of the token list and crash. --- blueprintcompiler/parse_tree.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blueprintcompiler/parse_tree.py b/blueprintcompiler/parse_tree.py index 338f24b..e56a220 100644 --- a/blueprintcompiler/parse_tree.py +++ b/blueprintcompiler/parse_tree.py @@ -371,6 +371,9 @@ class Until(ParseNode): def _parse(self, ctx): while not self.delimiter.parse(ctx).succeeded(): + if ctx.is_eof(): + return False + try: if not self.child.parse(ctx).matched(): ctx.skip_unexpected_token() @@ -378,9 +381,6 @@ class Until(ParseNode): ctx.errors.append(e) ctx.next_token() - if ctx.is_eof(): - return True - return True