]> granicus.if.org Git - vim/commitdiff
patch 8.1.2200: crash when memory allocation fails v8.1.2200
authorBram Moolenaar <Bram@vim.org>
Tue, 22 Oct 2019 19:54:31 +0000 (21:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 22 Oct 2019 19:54:31 +0000 (21:54 +0200)
Problem:    Crash when memory allocation fails.
Solution:   Check for NULL curwin and curbuf. (Christian Brabandt,
            closes #4839)

src/getchar.c
src/version.c

index f9bfab8297007728f2f7f28c31bcf0029cf33538..07383da2cab01577c2e1decd2774ed7eaaa2113c 100644 (file)
@@ -2059,8 +2059,8 @@ f_getcharmod(typval_T *argvars UNUSED, typval_T *rettv)
     void
 parse_queued_messages(void)
 {
-    int            old_curwin_id = curwin->w_id;
-    int            old_curbuf_fnum = curbuf->b_fnum;
+    int            old_curwin_id;
+    int            old_curbuf_fnum;
     int            i;
     int            save_may_garbage_collect = may_garbage_collect;
     static int entered = 0;
@@ -2071,6 +2071,14 @@ parse_queued_messages(void)
     if (updating_screen)
        return;
 
+    // If memory allocation fails during startup we'll exit but curbuf or
+    // curwin could be NULL.
+    if (curbuf == NULL || curwin == NULL)
+       return;
+
+    old_curbuf_fnum = curbuf->b_fnum;
+    old_curwin_id = curwin->w_id;
+
     ++entered;
 
     // may_garbage_collect is set in main_loop() to do garbage collection when
index f6e0b76e6524af26872eea6dafd557f35d699956..60a690dec742b27e8ae4cd3e7204da205d21ad1c 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2200,
 /**/
     2199,
 /**/