From f722923493d5a8994997b0ddd6978f4d62405237 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 30 Jun 2017 17:47:22 -0700 Subject: [PATCH] Limit the search depth for skip_preceding_trees recovery --- src/runtime/parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index cfb1528b..db440e88 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -42,6 +42,7 @@ static const uint32_t SOFT_MAX_VERSION_COUNT = 10; static const uint32_t HARD_MAX_VERSION_COUNT = 18; +static const uint32_t MAX_PRECEDING_TREES_TO_SKIP = 32; typedef struct { Parser *parser; @@ -963,6 +964,7 @@ static bool parser__do_potential_reductions(Parser *self, StackVersion version) static StackIterateAction parser__skip_preceding_trees_callback( void *payload, TSStateId state, const TreeArray *trees, uint32_t tree_count) { + if (trees->size > MAX_PRECEDING_TREES_TO_SKIP) return StackIterateStop; if (tree_count > 0 && state != ERROR_STATE) { uint32_t bytes_skipped = 0; for (uint32_t i = 0; i < trees->size; i++) {