summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-11 14:19:58 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-11 14:19:58 +0100
commitcee52204ca030ce7814844e4dab8b4ed897ba3cc (patch)
treeecaed340ef62e0b346a7592cc5876f31e1b77f14 /src/buffer.c
parente49b4bb89505fad28cf89f0891aef3e2d397919e (diff)
patch 8.2.0371: crash with combination of terminal popup and autocmdv8.2.0371
Problem: Crash with combination of terminal popup and autocmd. Solution: Disallow closing a popup that is the current window. Add a check that the current buffer is valid. (closes #5754)
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 25620afb5d..2dcbae2aea 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -508,6 +508,7 @@ close_buffer(
int wipe_buf = (action == DOBUF_WIPE || action == DOBUF_WIPE_REUSE);
int del_buf = (action == DOBUF_DEL || wipe_buf);
+ CHECK_CURBUF;
/*
* Force unloading or deleting when 'bufhidden' says so.
* The caller must take care of NOT deleting/freeing when 'bufhidden' is
@@ -530,6 +531,7 @@ close_buffer(
#ifdef FEAT_TERMINAL
if (bt_terminal(buf) && (buf->b_nwindows == 1 || del_buf))
{
+ CHECK_CURBUF;
if (term_job_running(buf->b_term))
{
if (wipe_buf || unload_buf)
@@ -554,6 +556,7 @@ close_buffer(
unload_buf = TRUE;
wipe_buf = TRUE;
}
+ CHECK_CURBUF;
}
#endif
@@ -743,6 +746,7 @@ aucmd_abort:
if (del_buf)
buf->b_p_bl = FALSE;
}
+ // NOTE: at this point "curbuf" may be invalid!
}
/*
@@ -933,7 +937,11 @@ free_buffer(buf_T *buf)
au_pending_free_buf = buf;
}
else
+ {
vim_free(buf);
+ if (curbuf == buf)
+ curbuf = NULL; // make clear it's not to be used
+ }
}
/*