]> granicus.if.org Git - vim/commitdiff
patch 8.1.1898: crash when out of memory during startup v8.1.1898
authorBram Moolenaar <Bram@vim.org>
Wed, 21 Aug 2019 11:06:55 +0000 (13:06 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 21 Aug 2019 11:06:55 +0000 (13:06 +0200)
Problem:    Crash when out of memory during startup.
Solution:   When out of memory message given during initialisation bail out.
            (closes #4842)

src/misc2.c
src/version.c

index db8392ccc685a1cf0efc10b0c05b30b684520208..8cdd0d453445f7965fdb6dbea889f20940e1c768 100644 (file)
@@ -1014,14 +1014,19 @@ do_outofmem_msg(size_t size)
 {
     if (!did_outofmem_msg)
     {
-       /* Don't hide this message */
+       // Don't hide this message
        emsg_silent = 0;
 
-       /* Must come first to avoid coming back here when printing the error
-        * message fails, e.g. when setting v:errmsg. */
+       // Must come first to avoid coming back here when printing the error
+       // message fails, e.g. when setting v:errmsg.
        did_outofmem_msg = TRUE;
 
        semsg(_("E342: Out of memory!  (allocating %lu bytes)"), (long_u)size);
+
+       if (starting == NO_SCREEN)
+           // Not even finished with initializations and already out of
+           // memory?  Then nothing is going to work, exit.
+           mch_exit(123);
     }
 }
 
index 14a9528bc6839d4d091c784da7d96a48e29f7c98..0689e0345c8f370ae0cd96962003f0e37b17cd0c 100644 (file)
@@ -765,6 +765,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1898,
 /**/
     1897,
 /**/