]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.1845: may use NULL pointer when running out of memory v8.1.1845
authorBram Moolenaar <Bram@vim.org>
Tue, 13 Aug 2019 21:09:49 +0000 (23:09 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 13 Aug 2019 21:09:49 +0000 (23:09 +0200)
Problem:    May use NULL pointer when running out of memory.
Solution:   Do not clear popup buffers when NULL. (closes #4802)

src/screen.c
src/version.c

index 55437e14766074166456589d7946be09374c0b9d..72b346d96d30a4bad9919df1bcb5587984cfe05d 100644 (file)
@@ -8645,10 +8645,16 @@ give_up:
        }
        /* Use the last line of the screen for the current line. */
        current_ScreenLine = new_ScreenLines + Rows * Columns;
+
+#ifdef FEAT_TEXT_PROP
+       vim_memset(new_popup_mask, 0, Rows * Columns * sizeof(short));
+       vim_memset(new_popup_transparent, 0, Rows * Columns * sizeof(char));
+#endif
     }
 
     free_screenlines();
 
+    // NOTE: this may result in all pointers to become NULL.
     ScreenLines = new_ScreenLines;
     ScreenLinesUC = new_ScreenLinesUC;
     for (i = 0; i < p_mco; ++i)
@@ -8661,10 +8667,8 @@ give_up:
     TabPageIdxs = new_TabPageIdxs;
 #ifdef FEAT_TEXT_PROP
     popup_mask = new_popup_mask;
-    vim_memset(popup_mask, 0, Rows * Columns * sizeof(short));
     popup_mask_next = new_popup_mask_next;
     popup_transparent = new_popup_transparent;
-    vim_memset(popup_transparent, 0, Rows * Columns * sizeof(char));
     popup_mask_refresh = TRUE;
 #endif
 
index f998c52586060ca468913707b3b9cc1bc64ee7a5..71f6c34f382900aeb4f65b0173f89cc38bae4f13 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1845,
 /**/
     1844,
 /**/