From 392e8ea749ffab10d70cc17104369c1a2796e199 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 8 Nov 2018 12:47:49 -0800 Subject: [PATCH] Fix loophole in error recovery infinite loop guard --- src/runtime/stack.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/stack.c b/src/runtime/stack.c index 1cb526eb..8268b2a8 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -583,14 +583,16 @@ int ts_stack_dynamic_precedence(Stack *self, StackVersion version) { bool ts_stack_has_advanced_since_error(const Stack *self, StackVersion version) { const StackHead *head = array_get(&self->heads, version); const StackNode *node = head->node; - if (node->error_cost == 0) return true; while (node) { if (node->link_count > 0) { Subtree subtree = node->links[0].subtree; if (subtree.ptr) { if (ts_subtree_total_bytes(subtree) > 0) { return true; - } else if (node->node_count > head->node_count_at_last_error) { + } else if ( + node->node_count > head->node_count_at_last_error && + ts_subtree_error_cost(subtree) == 0 + ) { node = node->links[0].node; continue; }