aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Vigouroux <tomvig38@gmail.com>2020-11-18 18:43:02 +0100
committerGitHub <noreply@github.com>2020-11-18 18:43:02 +0100
commit790fd58714a98e7910a4a0a56f85fb568f35d52c (patch)
treeb013ee8fb4a3624079914a7ff7e02e0b8058ac12
parent8c4648421a1e34c3e95e42ea596de36987f02563 (diff)
parent2f8eaad6d851e05b451328bedfc795a654102ced (diff)
downloadrneovim-790fd58714a98e7910a4a0a56f85fb568f35d52c.tar.gz
rneovim-790fd58714a98e7910a4a0a56f85fb568f35d52c.tar.bz2
rneovim-790fd58714a98e7910a4a0a56f85fb568f35d52c.zip
Merge pull request #13318 from tjdevries/fix_vigouxs_segfaulting_mistakes
fix: NULL segfaults brought to you by @vigoux
-rw-r--r--src/nvim/lua/treesitter.c4
1 files changed, 3 insertions, 1 deletions
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);
}