diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-10-20 20:12:08 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-10-21 07:34:06 -0400 |
commit | c067efa696698d455d9a1488c26e0fb5d8cb5bf5 (patch) | |
tree | 52d3d1834007ec83923f0af8c08433470875f748 /src/nvim/ex_docmd.c | |
parent | 13a6878d187612721baecede181e7dfdc3699a59 (diff) | |
download | rneovim-c067efa696698d455d9a1488c26e0fb5d8cb5bf5.tar.gz rneovim-c067efa696698d455d9a1488c26e0fb5d8cb5bf5.tar.bz2 rneovim-c067efa696698d455d9a1488c26e0fb5d8cb5bf5.zip |
vim-patch:8.1.2197: ExitPre autocommand may cause accessing freed memory
Problem: ExitPre autocommand may cause accessing freed memory.
Solution: Check the window pointer is still valid. (closes vim/vim#5093)
https://github.com/vim/vim/commit/34ba06b6e6f94bb46062e6c85dbfdcbb0d255ada
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 0da2cd67d6..ae3fb4fbfb 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6070,9 +6070,11 @@ static bool before_quit_autocmds(win_T *wp, bool quit_all, int forceit) if (quit_all || (check_more(false, forceit) == OK && only_one_window())) { apply_autocmds(EVENT_EXITPRE, NULL, NULL, false, curbuf); - // Refuse to quit when locked or when the buffer in the last window is - // being closed (can only happen in autocommands). - if (curbuf_locked() + // Refuse to quit when locked or when the window was closed or the + // buffer in the last window is being closed (can only happen in + // autocommands). + if (!win_valid(wp) + || curbuf_locked() || (curbuf->b_nwindows == 1 && curbuf->b_locked > 0)) { return true; } |