Merge #2138 'syntax.c: Prevent use after free for variable g:colors_name'

This commit is contained in:
Justin M. Keyes 2015-03-13 17:29:25 -04:00
commit 3e9ca91ff6
2 changed files with 15 additions and 4 deletions

View File

@ -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.

View File

@ -178,6 +178,10 @@ static char *(features[]) = {
// clang-format off
static int included_patches[] = {
//662,
//661,
660,
//659,
//658,
//657,
//656,