Mercurial > vim
changeset 12397:2bac51746e2b v8.0.1078
patch 8.0.1078: using freed memory with ":hi Normal"
commit https://github.com/vim/vim/commit/b4ea1914b8ca7c368253bd96e6b3cb9e3392da1c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 9 15:28:14 2017 +0200
patch 8.0.1078: using freed memory with ":hi Normal"
Problem: Using freed memory with ":hi Normal".
Solution: Get "item" again after updating the table.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 09 Sep 2017 15:30:04 +0200 |
parents | 89797da758ac |
children | eac3e2671dc8 |
files | src/syntax.c src/version.c |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/syntax.c +++ b/src/syntax.c @@ -7381,6 +7381,9 @@ do_highlight( # define is_menu_group 0 # define is_tooltip_group 0 #endif +#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) + int did_highlight_changed = FALSE; +#endif /* * If no argument, list current highlighting. @@ -7568,8 +7571,9 @@ do_highlight( #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) if (USE_24BIT) highlight_gui_started(); -#endif - highlight_changed(); + else +#endif + highlight_changed(); redraw_later_clear(); return; } @@ -8174,7 +8178,12 @@ do_highlight( #endif #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) if (USE_24BIT) + { highlight_gui_started(); + item = &HL_TABLE()[idx]; /* table may have changed */ + did_highlight_changed = TRUE; + redraw_all_later(NOT_VALID); + } #endif } #ifdef FEAT_GUI_X11 @@ -8210,7 +8219,11 @@ do_highlight( /* Only call highlight_changed() once, after a sequence of highlight * commands, and only if an attribute actually changed. */ - if (memcmp(item, &item_before, sizeof(item_before)) != 0) + if (memcmp(item, &item_before, sizeof(item_before)) != 0 +#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) + && !did_highlight_changed +#endif + ) { redraw_all_later(NOT_VALID); need_highlight_changed = TRUE;