aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_cmds.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index a71ee7a2fe..ef9affcdf6 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -10,6 +10,7 @@
* ex_cmds.c: some functions for command line commands
*/
+#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>
@@ -2765,9 +2766,12 @@ do_ecmd (
/* Autocommands may open a new window and leave oldwin open
* which leads to crashes since the above call sets
* oldwin->w_buffer to NULL. */
- if (curwin != oldwin && oldwin != aucmd_win
- && win_valid(oldwin) && oldwin->w_buffer == NULL)
- win_close(oldwin, FALSE);
+ if (curwin != oldwin && oldwin != aucmd_win && win_valid(oldwin)) {
+ assert(oldwin);
+ if (oldwin->w_buffer == NULL) {
+ win_close(oldwin, FALSE);
+ }
+ }
if (aborting()) { /* autocmds may abort script processing */
free(new_name);