From f0ca2283b08aa1f43eb14d6d4bae18272c2111f1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Jul 2018 23:36:32 -0400 Subject: vim-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. https://github.com/vim/vim/commit/b4ea1914b8ca7c368253bd96e6b3cb9e3392da1c --- src/nvim/syntax.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index dcac907c5a..39a2abe03d 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6500,6 +6500,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) bool error = false; int color; bool is_normal_group = false; // "Normal" group + bool did_highlight_changed = false; // If no argument, list current highlighting. if (ends_excmd((uint8_t)(*line))) { @@ -6944,6 +6945,9 @@ void do_highlight(const char *line, const bool forceit, const bool init) // redraw below will still handle usages of guibg=fg etc. ui_default_colors_set(); } + item = &HL_TABLE()[idx]; + did_highlight_changed = true; + redraw_all_later(NOT_VALID); } else { set_hl_attr(idx); } @@ -6954,7 +6958,8 @@ void do_highlight(const char *line, const bool forceit, const bool init) // 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 + && !did_highlight_changed) { redraw_all_later(NOT_VALID); need_highlight_changed = true; } -- cgit