aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/syntax.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-05-31 16:17:45 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-06-04 20:52:52 -0400
commit310a56d0a05deceea7df5a74f418f1df322ec9e1 (patch)
treed313b93bc4bc1f18700323e97f01b7b8d030a86c /src/nvim/syntax.c
parent64a2884d4cc78e3bbf1632cfe18d9e60a787a93e (diff)
downloadrneovim-310a56d0a05deceea7df5a74f418f1df322ec9e1.tar.gz
rneovim-310a56d0a05deceea7df5a74f418f1df322ec9e1.tar.bz2
rneovim-310a56d0a05deceea7df5a74f418f1df322ec9e1.zip
vim-patch:8.1.1895: using NULL pointer when out of memory
Problem: Using NULL pointer when out of memory. Solution: Bail out or skip the code using the pointer. (Zu-Ming Jiang, closes vim/vim#4805, closes vim/vim#4843, closes vim/vim#4939, closes vim/vim#4844) https://github.com/vim/vim/commit/6f10c70b59fa4e56aa479345fb0caeaac7429bfb
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r--src/nvim/syntax.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index ef4dfb3caa..f3b05c3961 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -7444,6 +7444,8 @@ static int syn_add_group(char_u *name)
return 0;
}
+ char_u *const name_up = vim_strsave_up(name);
+
// Append another syntax_highlight entry.
struct hl_group* hlgp = GA_APPEND_VIA_PTR(struct hl_group, &highlight_ga);
memset(hlgp, 0, sizeof(*hlgp));
@@ -7452,7 +7454,7 @@ static int syn_add_group(char_u *name)
hlgp->sg_rgb_fg = -1;
hlgp->sg_rgb_sp = -1;
hlgp->sg_blend = -1;
- hlgp->sg_name_u = vim_strsave_up(name);
+ hlgp->sg_name_u = name_up;
return highlight_ga.ga_len; /* ID is index plus one */
}