Fix crash in ts_node_field_name_for_child when no children are present

This commit is contained in:
Sebastian Lackner 2021-11-04 00:58:48 +01:00
parent 3739b7794e
commit 1245d54fb8

View file

@ -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,