From 3e3b7b14eb5ab39b8310868739890debb9e02447 Mon Sep 17 00:00:00 2001 From: duckdoom4 <60387522+duckdoom4@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:26:07 +0200 Subject: [PATCH] Fix crash on syntax error --- src/tokenizer/tokenizer.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tokenizer/tokenizer.ts b/src/tokenizer/tokenizer.ts index 5ddfe69..40050c8 100644 --- a/src/tokenizer/tokenizer.ts +++ b/src/tokenizer/tokenizer.ts @@ -307,6 +307,10 @@ class DocumentTokenizer { * @param caret The reader head position within the document */ private applyCaptures(captures: TokenPatternCapture, match: RegExpExecArray, source: string, parentNode: TreeNode) { + if (match.indices === undefined) { + return; // syntax error + } + let rootNode = parentNode; if (captures[0] !== undefined) {