Mercurial > vim
comparison src/syntax.c @ 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 | 972732a27d7c |
children | c14c81302b75 |
comparison
equal
deleted
inserted
replaced
12396:89797da758ac | 12397:2bac51746e2b |
---|---|
7379 int do_colors = FALSE; /* need to update colors? */ | 7379 int do_colors = FALSE; /* need to update colors? */ |
7380 #else | 7380 #else |
7381 # define is_menu_group 0 | 7381 # define is_menu_group 0 |
7382 # define is_tooltip_group 0 | 7382 # define is_tooltip_group 0 |
7383 #endif | 7383 #endif |
7384 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
7385 int did_highlight_changed = FALSE; | |
7386 #endif | |
7384 | 7387 |
7385 /* | 7388 /* |
7386 * If no argument, list current highlighting. | 7389 * If no argument, list current highlighting. |
7387 */ | 7390 */ |
7388 if (ends_excmd(*line)) | 7391 if (ends_excmd(*line)) |
7566 highlight_clear(idx); | 7569 highlight_clear(idx); |
7567 init_highlight(TRUE, TRUE); | 7570 init_highlight(TRUE, TRUE); |
7568 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | 7571 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
7569 if (USE_24BIT) | 7572 if (USE_24BIT) |
7570 highlight_gui_started(); | 7573 highlight_gui_started(); |
7571 #endif | 7574 else |
7572 highlight_changed(); | 7575 #endif |
7576 highlight_changed(); | |
7573 redraw_later_clear(); | 7577 redraw_later_clear(); |
7574 return; | 7578 return; |
7575 } | 7579 } |
7576 name_end = skiptowhite(line); | 7580 name_end = skiptowhite(line); |
7577 linep = skipwhite(name_end); | 7581 linep = skipwhite(name_end); |
8172 * and/or "fg", which have been changed now. | 8176 * and/or "fg", which have been changed now. |
8173 */ | 8177 */ |
8174 #endif | 8178 #endif |
8175 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | 8179 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
8176 if (USE_24BIT) | 8180 if (USE_24BIT) |
8181 { | |
8177 highlight_gui_started(); | 8182 highlight_gui_started(); |
8183 item = &HL_TABLE()[idx]; /* table may have changed */ | |
8184 did_highlight_changed = TRUE; | |
8185 redraw_all_later(NOT_VALID); | |
8186 } | |
8178 #endif | 8187 #endif |
8179 } | 8188 } |
8180 #ifdef FEAT_GUI_X11 | 8189 #ifdef FEAT_GUI_X11 |
8181 # ifdef FEAT_MENU | 8190 # ifdef FEAT_MENU |
8182 else if (is_menu_group) | 8191 else if (is_menu_group) |
8208 vim_free(key); | 8217 vim_free(key); |
8209 vim_free(arg); | 8218 vim_free(arg); |
8210 | 8219 |
8211 /* Only call highlight_changed() once, after a sequence of highlight | 8220 /* Only call highlight_changed() once, after a sequence of highlight |
8212 * commands, and only if an attribute actually changed. */ | 8221 * commands, and only if an attribute actually changed. */ |
8213 if (memcmp(item, &item_before, sizeof(item_before)) != 0) | 8222 if (memcmp(item, &item_before, sizeof(item_before)) != 0 |
8223 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
8224 && !did_highlight_changed | |
8225 #endif | |
8226 ) | |
8214 { | 8227 { |
8215 redraw_all_later(NOT_VALID); | 8228 redraw_all_later(NOT_VALID); |
8216 need_highlight_changed = TRUE; | 8229 need_highlight_changed = TRUE; |
8217 } | 8230 } |
8218 } | 8231 } |