Mercurial > vim
diff src/syntax.c @ 6671:476a12a96bb1 v7.4.660
updated for version 7.4.660
Problem: Using freed memory when g:colors_name is changed in the colors
script. (oni-link)
Solution: Make a copy of the variable value.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 13 Mar 2015 12:53:37 +0100 |
parents | d6473d6501fd |
children | 67e7a819c811 |
line wrap: on
line diff
--- a/src/syntax.c +++ b/src/syntax.c @@ -6988,8 +6988,22 @@ init_highlight(both, reset) * and 'background' or 't_Co' is changed. */ p = get_var_value((char_u *)"g:colors_name"); - if (p != NULL && load_colors(p) == OK) - return; + if (p != NULL) + { + /* The value of g:colors_name could be freed when sourcing the script, + * making "p" invalid, so copy it. */ + char_u *copy_p = vim_strsave(p); + int r; + + if (copy_p != NULL) + { + r = load_colors(copy_p); + vim_free(copy_p); + if (r == OK) + return; + } + } + #endif /*