Fix errors in when languages have no fields

This commit is contained in:
Max Brunsfeld 2019-02-12 17:20:12 -08:00
parent 56309a1c28
commit 9f608435ee
4 changed files with 72 additions and 13 deletions

View file

@ -284,6 +284,10 @@ TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *_self) {
const char *ts_tree_cursor_current_field_name(const TSTreeCursor *_self) {
TSFieldId id = ts_tree_cursor_current_field_id(_self);
const TreeCursor *self = (const TreeCursor *)_self;
return self->tree->language->field_names[id];
if (id) {
const TreeCursor *self = (const TreeCursor *)_self;
return self->tree->language->field_names[id];
} else {
return NULL;
}
}