Avoid using recursion for ts_subtree_compare

This can lead to stack overflow crashes.
This commit is contained in:
Max Brunsfeld 2023-11-27 10:43:30 -08:00
parent ac29eab5f9
commit 5e2456c2f2
3 changed files with 26 additions and 16 deletions

View file

@ -747,7 +747,7 @@ static bool ts_parser__select_tree(TSParser *self, Subtree left, Subtree right)
if (ts_subtree_error_cost(left) > 0) return true;
int comparison = ts_subtree_compare(left, right);
int comparison = ts_subtree_compare(left, right, &self->tree_pool);
switch (comparison) {
case -1:
LOG("select_earlier symbol:%s, over_symbol:%s", TREE_NAME(left), TREE_NAME(right));