summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-02-05 14:13:20 +0100
committerBram Moolenaar <Bram@vim.org>2017-02-05 14:13:20 +0100
commitaaaf57d8a936efe420190c077e4a74041cc6c72e (patch)
tree3c434fd48844736ed55f5ee05d9c4b5fc777a744
parent1fb0d49803b4f57025ed6a43b1f5b9eb91524645 (diff)
patch 8.0.0305: invalid memory access when option has duplicate flagv8.0.0305
Problem: Invalid memory access when option has duplicate flag. Solution: Correct pointer computation. (Dominique Pelle, closes #1442)
-rw-r--r--src/option.c7
-rw-r--r--src/testdir/test_options.vim6
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 3 deletions
diff --git a/src/option.c b/src/option.c
index 1237d048ba..32e97c99ba 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4954,7 +4954,7 @@ do_set(
if (flags & P_FLAGLIST)
{
/* Remove flags that appear twice. */
- for (s = newval; *s; ++s)
+ for (s = newval; *s;)
{
/* if options have P_FLAGLIST and
* P_ONECOMMA such as 'whichwrap' */
@@ -4966,7 +4966,7 @@ do_set(
/* Remove the duplicated value and
* the next comma. */
STRMOVE(s, s + 2);
- s -= 2;
+ continue;
}
}
else
@@ -4975,9 +4975,10 @@ do_set(
&& vim_strchr(s + 1, *s) != NULL)
{
STRMOVE(s, s + 1);
- --s;
+ continue;
}
}
+ ++s;
}
}
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index bfa942715d..ce59ae11b7 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -13,6 +13,12 @@ function! Test_whichwrap()
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
+ set whichwrap=h,h
+ call assert_equal('h', &whichwrap)
+
+ set whichwrap=h,h,h
+ call assert_equal('h', &whichwrap)
+
set whichwrap&
endfunction
diff --git a/src/version.c b/src/version.c
index 9273b2baa4..78cb27fe64 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 305,
+/**/
304,
/**/
303,