Mercurial > vim
comparison src/spell.c @ 30558:8e73ecbee60d v9.0.0614
patch 9.0.0614: SpellFileMissing autocmd may delete buffer
Commit: https://github.com/vim/vim/commit/ef976323e770315b5fca544efb6b2faa25674d15
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 28 11:48:30 2022 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 28 Sep 2022 13:00:04 +0200 |
parents | 087c42245022 |
children | c7983f593fa7 |
comparison
equal
deleted
inserted
replaced
30557:cb23c106452e | 30558:8e73ecbee60d |
---|---|
1566 // It's truncated when an error is detected. | 1566 // It's truncated when an error is detected. |
1567 STRCPY(sl.sl_lang, lang); | 1567 STRCPY(sl.sl_lang, lang); |
1568 sl.sl_slang = NULL; | 1568 sl.sl_slang = NULL; |
1569 sl.sl_nobreak = FALSE; | 1569 sl.sl_nobreak = FALSE; |
1570 | 1570 |
1571 // Disallow deleting the current buffer. Autocommands can do weird things | |
1572 // and cause "lang" to be freed. | |
1573 ++curbuf->b_locked; | |
1574 | |
1571 // We may retry when no spell file is found for the language, an | 1575 // We may retry when no spell file is found for the language, an |
1572 // autocommand may load it then. | 1576 // autocommand may load it then. |
1573 for (round = 1; round <= 2; ++round) | 1577 for (round = 1; round <= 2; ++round) |
1574 { | 1578 { |
1575 /* | 1579 /* |
1619 { | 1623 { |
1620 // At least one file was loaded, now load ALL the additions. | 1624 // At least one file was loaded, now load ALL the additions. |
1621 STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl"); | 1625 STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl"); |
1622 do_in_runtimepath(fname_enc, DIP_ALL, spell_load_cb, &sl); | 1626 do_in_runtimepath(fname_enc, DIP_ALL, spell_load_cb, &sl); |
1623 } | 1627 } |
1628 | |
1629 --curbuf->b_locked; | |
1624 } | 1630 } |
1625 | 1631 |
1626 /* | 1632 /* |
1627 * Return the encoding used for spell checking: Use 'encoding', except that we | 1633 * Return the encoding used for spell checking: Use 'encoding', except that we |
1628 * use "latin1" for "latin9". And limit to 60 characters (just in case). | 1634 * use "latin1" for "latin9". And limit to 60 characters (just in case). |