]> granicus.if.org Git - vim/commitdiff
patch 8.0.1225: no check for spell region being zero v8.0.1225
authorBram Moolenaar <Bram@vim.org>
Thu, 26 Oct 2017 22:57:05 +0000 (00:57 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 26 Oct 2017 22:57:05 +0000 (00:57 +0200)
Problem:    No check for spell region being zero. (geeknik)
Solution:   Check for zero. (closes #2252)

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

index 6188aaf40ce3e2f9a6b89450074c89a554e94a53..f6d7a6432f07a01a26eb50eb6a5fa2b9ee66e016 100644 (file)
@@ -4277,7 +4277,7 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
                    flags |= WF_REGION;
 
                    l = *p - '0';
-                   if (l > spin->si_region_count)
+                   if (l == 0 || l > spin->si_region_count)
                    {
                        smsg((char_u *)_("Invalid region nr in %s line %d: %s"),
                                                          fname, lnum, p);
index e4c236c968f9a53a5a189bc0a2d56827003f1b1a..54209fec724e88e2de00e93aa6161d6d498e7a0e 100644 (file)
@@ -271,6 +271,15 @@ func Test_zz_sal_and_addition()
   call assert_equal("elekwint", SecondSpellWord())
 endfunc
 
+func Test_region_error()
+  messages clear
+  call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
+  mkspell! Xtest.latin1.add.spl Xtest.latin1.add
+  call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
+  call delete('Xtest.latin1.add')
+  call delete('Xtest.latin1.add.spl')
+endfunc
+
 " Check using z= in new buffer (crash fixed by patch 7.4a.028).
 func Test_zeq_crash()
   new
index 2b8fda7f3780e538303eb393e8e94bda0e531320..6ab4e75468debbf9cd0b47b135e2954bcb9cee3a 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1225,
 /**/
     1224,
 /**/