Mercurial > vim
changeset 31095:c61a9d832537 v9.0.0882
patch 9.0.0882: using freed memory after SpellFileMissing autocmd uses bwipe
Commit: https://github.com/vim/vim/commit/c3d27ada14acd02db357f2d16347acc22cb17e93
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 14 20:52:14 2022 +0000
patch 9.0.0882: using freed memory after SpellFileMissing autocmd uses bwipe
Problem: Using freed memory after SpellFileMissing autocmd uses bwipe.
Solution: Bail out if the window no longer exists.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Nov 2022 22:00:04 +0100 |
parents | 3a07a6df9786 |
children | 4d09d22a1c0d |
files | src/spell.c src/testdir/test_spell.vim src/version.c |
diffstat | 3 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/spell.c +++ b/src/spell.c @@ -2110,8 +2110,8 @@ did_set_spelllang(win_T *wp) { spell_load_lang(lang); // SpellFileMissing autocommands may do anything, including - // destroying the buffer we are using... - if (!bufref_valid(&bufref)) + // destroying the buffer we are using or closing the window. + if (!bufref_valid(&bufref) || !win_valid_any_tab(wp)) { ret_msg = N_(e_spellfilemising_autocommand_deleted_buffer); goto theend;
--- a/src/testdir/test_spell.vim +++ b/src/testdir/test_spell.vim @@ -159,6 +159,19 @@ func Test_spell_file_missing() %bwipe! endfunc +func Test_spell_file_missing_bwipe() + " this was using a window that was wiped out in a SpellFileMissing autocmd + set spelllang=xy + au SpellFileMissing * n0 + set spell + au SpellFileMissing * bw + snext somefile + + au! SpellFileMissing + bwipe! + set nospell spelllang=en +endfunc + func Test_spelldump() " In case the spell file is not found avoid getting the download dialog, we " would get stuck at the prompt.