diff src/ex_cmds.c @ 23845:7517eb94239b v8.2.2464

patch 8.2.2464: using freed memory if window closed in autocommand Commit: https://github.com/vim/vim/commit/8ab375706e6712308f8cf7529bcae56684a6f385 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 3 21:56:59 2021 +0100 patch 8.2.2464: using freed memory if window closed in autocommand Problem: Using freed memory if window closed in autocommand. (houyunsong) Solution: Check the window still exists.
author Bram Moolenaar <Bram@vim.org>
date Wed, 03 Feb 2021 22:00:04 +0100
parents 34a95c4bd647
children 5d11a15dbaa9
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2768,7 +2768,9 @@ do_ecmd(
 		did_decrement = close_buffer(oldwin, curbuf,
 			 (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE);
 
-		the_curwin->w_closing = FALSE;
+		// Autocommands may have closed the window.
+		if (win_valid(the_curwin))
+		    the_curwin->w_closing = FALSE;
 		--buf->b_locked;
 
 #ifdef FEAT_EVAL