From 6020e8b69ea59131be6fffd1667815f8742729db Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 16 Jan 2018 00:07:14 +0100 Subject: vim-patch:8.0.1225: no check for spell region being zero Problem: No check for spell region being zero. (geeknik) Solution: Check for zero. (closes vim/vim#2252) https://github.com/vim/vim/commit/ee03b941241eae1d36bc29b84eec09116cefe7cd --- src/nvim/spellfile.c | 2 +- src/nvim/testdir/test_spell.vim | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 1f7f616782..df066e7ad3 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -3656,7 +3656,7 @@ static int 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(_("Invalid region nr in %s line %d: %s"), fname, lnum, p); break; diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index c7b4b60b6c..8165128fa3 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -272,6 +272,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 -- cgit