patch 8.2.4428: crash when switching tabpage while in the cmdline window
Problem: Crash when switching tabpage while in the cmdline window.
Solution: Disallow switching tabpage when in the cmdline window.
diff --git a/src/window.c b/src/window.c
index 1f5e709..b00ed97 100644
--- a/src/window.c
+++ b/src/window.c
@@ -111,6 +111,21 @@
#endif
/*
+ * Return the current window, unless in the cmdline window and "prevwin" is
+ * set, then return "prevwin".
+ */
+ win_T *
+prevwin_curwin(void)
+{
+ return
+#ifdef FEAT_CMDWIN
+ // In cmdwin, the alternative buffer should be used.
+ is_in_cmdwin() && prevwin != NULL ? prevwin :
+#endif
+ curwin;
+}
+
+/*
* All CTRL-W window commands are handled here, called from normal_cmd().
*/
void
@@ -3927,6 +3942,14 @@
tabpage_T *newtp;
int n;
+#ifdef FEAT_CMDWIN
+ if (cmdwin_type != 0)
+ {
+ emsg(_(e_invalid_in_cmdline_window));
+ return FAIL;
+ }
+#endif
+
newtp = alloc_tabpage();
if (newtp == NULL)
return FAIL;
@@ -4301,6 +4324,7 @@
text_locked_msg();
return;
}
+ CHECK_CMDWIN;
// If there is only one it can't work.
if (first_tabpage->tp_next == NULL)
@@ -4368,6 +4392,8 @@
int trigger_enter_autocmds,
int trigger_leave_autocmds)
{
+ CHECK_CMDWIN;
+
// Don't repeat a message in another tab page.
set_keep_msg(NULL, 0);