diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-03-13 12:53:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-03-13 12:53:37 +0100 |
commit | c7dc1f4a53fdb26b88c484003142c575655481b7 (patch) | |
tree | 22b0474fe00822ad8280d471eb9dce1e43f9f1d4 /src/syntax.c | |
parent | 488eb26ec7fda1dc79f3d856d40da072332630b6 (diff) | |
download | vim-git-c7dc1f4a53fdb26b88c484003142c575655481b7.tar.gz |
updated for version 7.4.660v7.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.
Diffstat (limited to 'src/syntax.c')
-rw-r--r-- | src/syntax.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/syntax.c b/src/syntax.c index 483a9b02f..788a9f5aa 100644 --- 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 /* |