diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-28 11:48:30 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-28 11:48:30 +0100 |
commit | ef976323e770315b5fca544efb6b2faa25674d15 (patch) | |
tree | bcbbeb67ecb9b2a445919e837089b682fd943d10 /src/spell.c | |
parent | caa1d19da1cdfd07f93b578b4fd5214a53197cd6 (diff) | |
download | vim-git-ef976323e770315b5fca544efb6b2faa25674d15.tar.gz |
patch 9.0.0614: SpellFileMissing autocmd may delete bufferv9.0.0614
Problem: SpellFileMissing autocmd may delete buffer.
Solution: Disallow deleting the current buffer to avoid using freed memory.
Diffstat (limited to 'src/spell.c')
-rw-r--r-- | src/spell.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/spell.c b/src/spell.c index 628814fe6..975b5a678 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1568,6 +1568,10 @@ spell_load_lang(char_u *lang) sl.sl_slang = NULL; sl.sl_nobreak = FALSE; + // Disallow deleting the current buffer. Autocommands can do weird things + // and cause "lang" to be freed. + ++curbuf->b_locked; + // We may retry when no spell file is found for the language, an // autocommand may load it then. for (round = 1; round <= 2; ++round) @@ -1621,6 +1625,8 @@ spell_load_lang(char_u *lang) STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl"); do_in_runtimepath(fname_enc, DIP_ALL, spell_load_cb, &sl); } + + --curbuf->b_locked; } /* |