]> granicus.if.org Git - vim/commitdiff
patch 8.1.1824: crash when correctly spelled word is very long v8.1.1824
authorBram Moolenaar <Bram@vim.org>
Tue, 6 Aug 2019 20:48:02 +0000 (22:48 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 6 Aug 2019 20:48:02 +0000 (22:48 +0200)
Problem:    Crash when correctly spelled word is very long. (Ben Kraft)
Solution:   Check word length before copying. (closes #4778)

src/spell.c
src/testdir/test_spell.vim
src/version.c

index dda81d9d58ad3f5995aab9f74bc362c85771edf4..83c232c524b03f766d8f94190cd66c4b01e495f9 100644 (file)
@@ -2073,6 +2073,8 @@ count_common_word(
 
     if (len == -1)
        p = word;
+    else if (len >= MAXWLEN)
+       return;
     else
     {
        vim_strncpy(buf, word, len);
index 48bc3b3e2eac67182b48b1d55509a560d3e911b2..af72637ce37c4e9fb4b0fe97ba6f9749f7e5ded3 100644 (file)
@@ -1,4 +1,5 @@
 " Test spell checking
+" Note: this file uses latin1 encoding, but is used with utf-8 encoding.
 
 source check.vim
 CheckFeature spell
@@ -398,6 +399,18 @@ func Test_zeq_crash()
   bwipe!
 endfunc
 
+" Check handling a word longer than MAXWLEN.
+func Test_spell_long_word()
+  set enc=utf-8
+  new
+  call setline(1, "d\xCC\xB4\xCC\xBD\xCD\x88\xCD\x94a\xCC\xB5\xCD\x84\xCD\x84\xCC\xA8\xCD\x9Cr\xCC\xB5\xCC\x8E\xCD\x85\xCD\x85k\xCC\xB6\xCC\x89\xCC\x9D \xCC\xB6\xCC\x83\xCC\x8F\xCC\xA4\xCD\x8Ef\xCC\xB7\xCC\x81\xCC\x80\xCC\xA9\xCC\xB0\xCC\xAC\xCC\xA2\xCD\x95\xCD\x87\xCD\x8D\xCC\x9E\xCD\x99\xCC\xAD\xCC\xAB\xCC\x97\xCC\xBBo\xCC\xB6\xCC\x84\xCC\x95\xCC\x8C\xCC\x8B\xCD\x9B\xCD\x9C\xCC\xAFr\xCC\xB7\xCC\x94\xCD\x83\xCD\x97\xCC\x8C\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xCD\x99\xCC\xB0\xCC\xA8\xCC\xA3\xCC\xA8\xCC\x96\xCC\x99\xCC\xAE\xCC\xBC\xCC\x99\xCD\x9A\xCC\xB2\xCC\xB1\xCC\x9F\xCC\xBB\xCC\xA6\xCD\x85\xCC\xAA\xCD\x89\xCC\x9D\xCC\x99\xCD\x96\xCC\xB1\xCC\xB1\xCC\x99\xCC\xA6\xCC\xA5\xCD\x95\xCC\xB2\xCC\xA0\xCD\x99 within")
+  set spell spelllang=en
+  redraw
+  redraw!
+  bwipe!
+  set nospell
+endfunc
+
 func LoadAffAndDic(aff_contents, dic_contents)
   set enc=latin1
   set spellfile=
index ec53de2d95566978bef9c3ffe88368cf7350dc0c..53c7a9d1ba00b452358e33d1810eda3f9e711458 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1824,
 /**/
     1823,
 /**/