From 5337a678fa28d0a7c35df90574b0349646087b06 Mon Sep 17 00:00:00 2001 From: Logan Collins Date: Mon, 31 Oct 2022 11:35:52 -0700 Subject: [PATCH] Resolving a potential crash freeing a null pointer when cancelling parses. --- lib/src/parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/parser.c b/lib/src/parser.c index a314089f..75305d4f 100644 --- a/lib/src/parser.c +++ b/lib/src/parser.c @@ -1461,7 +1461,9 @@ static bool ts_parser__advance( ((self->cancellation_flag && atomic_load(self->cancellation_flag)) || (!clock_is_null(self->end_clock) && clock_is_gt(clock_now(), self->end_clock))) ) { - ts_subtree_release(&self->tree_pool, lookahead); + if (lookahead.ptr) { + ts_subtree_release(&self->tree_pool, lookahead); + } return false; }