aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spell.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-10-15 16:10:56 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-10-15 16:28:36 +0800
commit6bc2d6b66b683faedded01128af8ad98b7130fef (patch)
treed0986b71d8922178c32e010bf4b5615f0e0d1cc9 /src/nvim/spell.c
parent65cbe0cc35c07a929152b86e78717efa4ba155da (diff)
downloadrneovim-6bc2d6b66b683faedded01128af8ad98b7130fef.tar.gz
rneovim-6bc2d6b66b683faedded01128af8ad98b7130fef.tar.bz2
rneovim-6bc2d6b66b683faedded01128af8ad98b7130fef.zip
vim-patch:9.0.0614: SpellFileMissing autocmd may delete buffer
Problem: SpellFileMissing autocmd may delete buffer. Solution: Disallow deleting the current buffer to avoid using freed memory. https://github.com/vim/vim/commit/ef976323e770315b5fca544efb6b2faa25674d15
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r--src/nvim/spell.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 7d2b58ff46..69c2b027bc 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -1511,6 +1511,10 @@ static void 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 (int round = 1; round <= 2; round++) {
@@ -1553,6 +1557,8 @@ static void spell_load_lang(char_u *lang)
STRCPY(fname_enc + strlen(fname_enc) - 3, "add.spl");
do_in_runtimepath((char *)fname_enc, DIP_ALL, spell_load_cb, &sl);
}
+
+ curbuf->b_locked--;
}
// Return the encoding used for spell checking: Use 'encoding', except that we