Skip to content

Commit 1245d54

Browse files
committed
Fix crash in ts_node_field_name_for_child when no children are present
1 parent 3739b77 commit 1245d54

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/src/node.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id) {
571571

572572
const char *ts_node_field_name_for_child(TSNode self, uint32_t child_index) {
573573
const TSFieldMapEntry *field_map_start = NULL, *field_map_end = NULL;
574+
if (!ts_node_child_count(self)) {
575+
return NULL;
576+
}
577+
574578
ts_language_field_map(
575579
self.tree->language,
576580
ts_node__subtree(self).ptr->production_id,

0 commit comments

Comments
 (0)