From 8c802da174801d684c6d529e835ea0633368247f Mon Sep 17 00:00:00 2001 From: WillLillis Date: Sat, 2 Nov 2024 00:53:03 -0400 Subject: [PATCH] fix(lib): check point, byte ranges in `node_descendant_for` functions --- lib/src/node.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/node.c b/lib/src/node.c index 0e141136..203b98c8 100644 --- a/lib/src/node.c +++ b/lib/src/node.c @@ -348,6 +348,9 @@ static inline TSNode ts_node__descendant_for_byte_range( uint32_t range_end, bool include_anonymous ) { + if (range_start > range_end) { + return ts_node__null(); + } TSNode node = self; TSNode last_visible_node = self; @@ -391,6 +394,9 @@ static inline TSNode ts_node__descendant_for_point_range( TSPoint range_end, bool include_anonymous ) { + if (point_gt(range_start, range_end)) { + return ts_node__null(); + } TSNode node = self; TSNode last_visible_node = self;