]> granicus.if.org Git - vim/commitdiff
patch 8.1.1259: crash when exiting early v8.1.1259
authorBram Moolenaar <Bram@vim.org>
Fri, 3 May 2019 21:15:37 +0000 (23:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 May 2019 21:15:37 +0000 (23:15 +0200)
Problem:    Crash when exiting early. (Ralf Schandl)
Solution:   Only pop/push the title when it was set. (closes #4334)

src/misc2.c
src/os_unix.c
src/tag.c
src/usercmd.c
src/version.c

index fe1438083ee0abd405781aa20e08d580194ccdbc..e615f96b505b17546469d817e37bb9d17e2de84f 100644 (file)
@@ -1068,7 +1068,7 @@ free_all_mem(void)
 
     /* Close all tabs and windows.  Reset 'equalalways' to avoid redraws. */
     p_ea = FALSE;
-    if (first_tabpage->tp_next != NULL)
+    if (first_tabpage != NULL && first_tabpage->tp_next != NULL)
        do_cmdline_cmd((char_u *)"tabonly!");
     if (!ONE_WINDOW)
        do_cmdline_cmd((char_u *)"only!");
@@ -1085,29 +1085,33 @@ free_all_mem(void)
     // Clear user commands (before deleting buffers).
     ex_comclear(NULL);
 
+    // When exiting from mainerr_arg_missing curbuf has not been initialized,
+    // and not much else.
+    if (curbuf != NULL)
+    {
 # ifdef FEAT_MENU
-    /* Clear menus. */
-    do_cmdline_cmd((char_u *)"aunmenu *");
+       // Clear menus.
+       do_cmdline_cmd((char_u *)"aunmenu *");
 #  ifdef FEAT_MULTI_LANG
-    do_cmdline_cmd((char_u *)"menutranslate clear");
+       do_cmdline_cmd((char_u *)"menutranslate clear");
 #  endif
 # endif
-
-    /* Clear mappings, abbreviations, breakpoints. */
-    do_cmdline_cmd((char_u *)"lmapclear");
-    do_cmdline_cmd((char_u *)"xmapclear");
-    do_cmdline_cmd((char_u *)"mapclear");
-    do_cmdline_cmd((char_u *)"mapclear!");
-    do_cmdline_cmd((char_u *)"abclear");
+       // Clear mappings, abbreviations, breakpoints.
+       do_cmdline_cmd((char_u *)"lmapclear");
+       do_cmdline_cmd((char_u *)"xmapclear");
+       do_cmdline_cmd((char_u *)"mapclear");
+       do_cmdline_cmd((char_u *)"mapclear!");
+       do_cmdline_cmd((char_u *)"abclear");
 # if defined(FEAT_EVAL)
-    do_cmdline_cmd((char_u *)"breakdel *");
+       do_cmdline_cmd((char_u *)"breakdel *");
 # endif
 # if defined(FEAT_PROFILE)
-    do_cmdline_cmd((char_u *)"profdel *");
+       do_cmdline_cmd((char_u *)"profdel *");
 # endif
 # if defined(FEAT_KEYMAP)
-    do_cmdline_cmd((char_u *)"set keymap=");
+       do_cmdline_cmd((char_u *)"set keymap=");
 #endif
+    }
 
 # ifdef FEAT_TITLE
     free_titles();
@@ -1142,7 +1146,8 @@ free_all_mem(void)
     set_expr_line(NULL);
 # endif
 # ifdef FEAT_DIFF
-    diff_clear(curtab);
+    if (curtab != NULL)
+       diff_clear(curtab);
 # endif
     clear_sb_text(TRUE);             /* free any scrollback text */
 
@@ -1172,17 +1177,18 @@ free_all_mem(void)
        tabpage_T   *tab;
 
        qf_free_all(NULL);
-       /* Free all location lists */
+       // Free all location lists
        FOR_ALL_TAB_WINDOWS(tab, win)
            qf_free_all(win);
     }
 #endif
 
-    /* Close all script inputs. */
+    // Close all script inputs.
     close_all_scripts();
 
-    /* Destroy all windows.  Must come before freeing buffers. */
-    win_free_all();
+    if (curwin != NULL)
+       // Destroy all windows.  Must come before freeing buffers.
+       win_free_all();
 
     /* Free all option values.  Must come after closing windows. */
     free_all_options();
@@ -1223,8 +1229,11 @@ free_all_mem(void)
 
     reset_last_sourcing();
 
-    free_tabpage(first_tabpage);
-    first_tabpage = NULL;
+    if (first_tabpage != NULL)
+    {
+       free_tabpage(first_tabpage);
+       first_tabpage = NULL;
+    }
 
 # ifdef UNIX
     /* Machine-specific free. */
index a78b330f23b9d31c52f43d9be9538f2db5081c5e..ba5d386bb1771294fa1a1657f8d85c6df3857eaa 100644 (file)
@@ -2205,14 +2205,19 @@ mch_settitle(char_u *title, char_u *icon)
     void
 mch_restore_title(int which)
 {
+    int        do_push_pop = did_set_title || did_set_icon;
+
     /* only restore the title or icon when it has been set */
     mch_settitle(((which & SAVE_RESTORE_TITLE) && did_set_title) ?
                        (oldtitle ? oldtitle : p_titleold) : NULL,
               ((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);
 
-    // pop and push from/to the stack
-    term_pop_title(which);
-    term_push_title(which);
+    if (do_push_pop)
+    {
+       // pop and push from/to the stack
+       term_pop_title(which);
+       term_push_title(which);
+    }
 }
 
 #endif /* FEAT_TITLE */
index 1242668a84bfce06ca0bd577786e45bcc67a9b24..2d46e14003c277652c4c8873f87501aa2d4401d1 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -2860,7 +2860,8 @@ found_tagfile_cb(char_u *fname, void *cookie UNUSED)
 free_tag_stuff(void)
 {
     ga_clear_strings(&tag_fnames);
-    do_tag(NULL, DT_FREE, 0, 0, 0);
+    if (curwin != NULL)
+       do_tag(NULL, DT_FREE, 0, 0, 0);
     tag_freematch();
 
 # if defined(FEAT_QUICKFIX)
index 37c519dfa981329f49d6bc0d5ebba2bd2ac5f911..ca01a3ca39fa132f10c1bdef976814764066789c 100644 (file)
@@ -1045,7 +1045,8 @@ ex_command(exarg_T *eap)
 ex_comclear(exarg_T *eap UNUSED)
 {
     uc_clear(&ucmds);
-    uc_clear(&curbuf->b_ucmds);
+    if (curbuf != NULL)
+       uc_clear(&curbuf->b_ucmds);
 }
 
 /*
index 69ab34b423d09d4109ed7d4efcd82b9002aa2019..c8bcdecf026906e66c93acb6c545fcbd8d16f2e6 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1259,
 /**/
     1258,
 /**/