From 2f8eaad6d851e05b451328bedfc795a654102ced Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 18 Nov 2020 11:16:38 -0500 Subject: fix: NULL segfaults brought to you by @vigoux --- src/nvim/lua/treesitter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/lua') diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 0515bbfe53..a9a57d386b 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -743,7 +743,9 @@ static int node_field(lua_State *L) if (ts_tree_cursor_goto_first_child(&cursor)) { do { - if (!STRCMP(field_name, ts_tree_cursor_current_field_name(&cursor))) { + const char *current_field = ts_tree_cursor_current_field_name(&cursor); + + if (current_field != NULL && !STRCMP(field_name, current_field)) { push_node(L, ts_tree_cursor_current_node(&cursor), 1); // [table, node] lua_rawseti(L, -2, ++curr_index); } -- cgit