aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-03-13 17:29:25 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-03-13 17:29:25 -0400
commit3e9ca91ff6832000340b4bda85ca2412f7d26dc7 (patch)
tree2edf011db99f37885956f654d146e3564b42b77a
parentbdbbdb5888e18025b0f95849a88fe6cb53454183 (diff)
parent0d8a10f6c5180511b36925bb7c66452c8126eb58 (diff)
downloadrneovim-3e9ca91ff6832000340b4bda85ca2412f7d26dc7.tar.gz
rneovim-3e9ca91ff6832000340b4bda85ca2412f7d26dc7.tar.bz2
rneovim-3e9ca91ff6832000340b4bda85ca2412f7d26dc7.zip
Merge #2138 'syntax.c: Prevent use after free for variable g:colors_name'
-rw-r--r--src/nvim/syntax.c15
-rw-r--r--src/nvim/version.c4
2 files changed, 15 insertions, 4 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 07f18bf93b..3f9466fd7c 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -5938,15 +5938,22 @@ init_highlight (
int i;
char **pp;
static int had_both = FALSE;
- char_u *p;
/*
* Try finding the color scheme file. Used when a color file was loaded
* and 'background' or 't_Co' is changed.
*/
- p = get_var_value((char_u *)"g:colors_name");
- if (p != NULL && load_colors(p) == OK)
- return;
+ char_u *p = get_var_value((char_u *)"g:colors_name");
+ if (p != NULL) {
+ // Value of g:colors_name could be freed in load_colors() and make
+ // p invalid, so copy it.
+ char_u *copy_p = vim_strsave(p);
+ bool okay = load_colors(copy_p);
+ free(copy_p);
+ if (okay) {
+ return;
+ }
+ }
/*
* Didn't use a color file, use the compiled-in colors.
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 4d25c63111..f876e78388 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -178,6 +178,10 @@ static char *(features[]) = {
// clang-format off
static int included_patches[] = {
+ //662,
+ //661,
+ 660,
+ //659,
//658,
//657,
//656,