summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-10-06 13:41:07 +0100
committerBram Moolenaar <Bram@vim.org>2021-10-06 13:41:07 +0100
commite275ba4fc994474155fbafe8b87a6d3b477456ba (patch)
tree6d474169be70959a09da92686e061901455691ba
parente2982d691186c8a9b16ecc8d831d2472088c8ed8 (diff)
downloadvim-git-e275ba4fc994474155fbafe8b87a6d3b477456ba.tar.gz
patch 8.2.3484: crash when going through spell suggestionsv8.2.3484
Problem: Crash when going through spell suggestions. Solution: Limit the text length for finding suggestions to the original length. Do not update buffers when exiting. (closes #8965)
-rw-r--r--src/clipboard.c3
-rw-r--r--src/spellsuggest.c5
-rw-r--r--src/testdir/test_spell_utf8.vim16
-rw-r--r--src/version.c2
4 files changed, 25 insertions, 1 deletions
diff --git a/src/clipboard.c b/src/clipboard.c
index b1da99bcb..c0c21aeb6 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -199,7 +199,8 @@ clip_lose_selection(Clipboard_T *cbd)
|| get_real_state() == SELECTMODE)
&& (cbd == &clip_star ?
clip_isautosel_star() : clip_isautosel_plus())
- && HL_ATTR(HLF_V) != HL_ATTR(HLF_VNC))
+ && HL_ATTR(HLF_V) != HL_ATTR(HLF_VNC)
+ && !exiting)
{
update_curbuf(INVERTED_ALL);
setcursor();
diff --git a/src/spellsuggest.c b/src/spellsuggest.c
index 2951eea2e..a6dbc78a4 100644
--- a/src/spellsuggest.c
+++ b/src/spellsuggest.c
@@ -1178,6 +1178,11 @@ suggest_try_change(suginfo_T *su)
p = su->su_badptr + su->su_badlen;
(void)spell_casefold(curwin, p, (int)STRLEN(p), fword + n, MAXWLEN - n);
+ // Make sure the resulting text is not longer than the original text.
+ n = (int)STRLEN(su->su_badptr);
+ if (n < MAXWLEN)
+ fword[n] = NUL;
+
for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi)
{
lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
diff --git a/src/testdir/test_spell_utf8.vim b/src/testdir/test_spell_utf8.vim
index 1f561e46a..79dc3e4a4 100644
--- a/src/testdir/test_spell_utf8.vim
+++ b/src/testdir/test_spell_utf8.vim
@@ -765,4 +765,20 @@ func Test_spellfile_value()
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
endfunc
+func Test_no_crash_with_weird_text()
+ new
+ let lines =<< trim END
+ r<sfile>
+ €
+
+
+ €
+ END
+ call setline(1, lines)
+ exe "%norm \<C-v>ez=>\<C-v>wzG"
+
+ bwipe!
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 03b7022ad..62c7f8f11 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3484,
+/**/
3483,
/**/
3482,