diff src/window.c @ 23869:5a4f9c5c1b99 v8.2.2476

patch 8.2.2476: using freed memory when splitting window while closing buffer Commit: https://github.com/vim/vim/commit/983d83ff1cd796ff321074335fa53fbe7ac45a46 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 7 12:12:43 2021 +0100 patch 8.2.2476: using freed memory when splitting window while closing buffer Problem: Using freed memory when using an autocommand to split a window while a buffer is being closed. Solution: Disallow splitting when the buffer has b_locked_split set.
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Feb 2021 12:15:03 +0100
parents 65718283239b
children b5a6de6a8915
line wrap: on
line diff
--- a/src/window.c
+++ b/src/window.c
@@ -769,6 +769,11 @@ check_split_disallowed()
 	emsg(_("E242: Can't split a window while closing another"));
 	return FAIL;
     }
+    if (curwin->w_buffer->b_locked_split)
+    {
+	emsg(_(e_cannot_split_window_when_closing_buffer));
+	return FAIL;
+    }
     return OK;
 }
 
@@ -793,6 +798,9 @@ win_split(int size, int flags)
     if (ERROR_IF_ANY_POPUP_WINDOW)
 	return FAIL;
 
+    if (check_split_disallowed() == FAIL)
+	return FAIL;
+
     // When the ":tab" modifier was used open a new tab page instead.
     if (may_open_tabpage() == OK)
 	return OK;
@@ -804,8 +812,6 @@ win_split(int size, int flags)
 	emsg(_("E442: Can't split topleft and botright at the same time"));
 	return FAIL;
     }
-    if (check_split_disallowed() == FAIL)
-	return FAIL;
 
     // When creating the help window make a snapshot of the window layout.
     // Otherwise clear the snapshot, it's now invalid.