From 1245d54fb806726b5fbd627fb8a91dd5e7e3680a Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 4 Nov 2021 00:58:48 +0100 Subject: [PATCH] Fix crash in ts_node_field_name_for_child when no children are present --- lib/src/node.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/node.c b/lib/src/node.c index 156b9a18..de59504e 100644 --- a/lib/src/node.c +++ b/lib/src/node.c @@ -571,6 +571,10 @@ recur: const char *ts_node_field_name_for_child(TSNode self, uint32_t child_index) { const TSFieldMapEntry *field_map_start = NULL, *field_map_end = NULL; + if (!ts_node_child_count(self)) { + return NULL; + } + ts_language_field_map( self.tree->language, ts_node__subtree(self).ptr->production_id,