]> granicus.if.org Git - vim/commitdiff
patch 8.0.1078: using freed memory with ":hi Normal" v8.0.1078
authorBram Moolenaar <Bram@vim.org>
Sat, 9 Sep 2017 13:28:14 +0000 (15:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 9 Sep 2017 13:28:14 +0000 (15:28 +0200)
Problem:    Using freed memory with ":hi Normal".
Solution:   Get "item" again after updating the table.

src/syntax.c
src/version.c

index ded6cd33d9aa177be67bc6b9ca349cf2a8143dda..1a425f76a6679032c630f6eff30764bc2cbf7d31 100644 (file)
@@ -7380,6 +7380,9 @@ do_highlight(
 #else
 # define is_menu_group 0
 # define is_tooltip_group 0
+#endif
+#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+    int                did_highlight_changed = FALSE;
 #endif
 
     /*
@@ -7568,8 +7571,9 @@ do_highlight(
 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
            if (USE_24BIT)
                highlight_gui_started();
+           else
 #endif
-           highlight_changed();
+               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;
index a54e153b28dcf536dc8b6a0fe868d85f59fb6b78..4ef0d9ee716725b5bb450db1c52102cbe3881b99 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1078,
 /**/
     1077,
 /**/