0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 8.0.0305: invalid memory access when option has duplicate flag

Problem:    Invalid memory access when option has duplicate flag.
Solution:   Correct pointer computation. (Dominique Pelle, closes #1442)
This commit is contained in:
Bram Moolenaar
2017-02-05 14:13:20 +01:00
parent 1fb0d49803
commit aaaf57d8a9
3 changed files with 12 additions and 3 deletions

View File

@@ -4954,7 +4954,7 @@ do_set(
if (flags & P_FLAGLIST) if (flags & P_FLAGLIST)
{ {
/* Remove flags that appear twice. */ /* Remove flags that appear twice. */
for (s = newval; *s; ++s) for (s = newval; *s;)
{ {
/* if options have P_FLAGLIST and /* if options have P_FLAGLIST and
* P_ONECOMMA such as 'whichwrap' */ * P_ONECOMMA such as 'whichwrap' */
@@ -4966,7 +4966,7 @@ do_set(
/* Remove the duplicated value and /* Remove the duplicated value and
* the next comma. */ * the next comma. */
STRMOVE(s, s + 2); STRMOVE(s, s + 2);
s -= 2; continue;
} }
} }
else else
@@ -4975,9 +4975,10 @@ do_set(
&& vim_strchr(s + 1, *s) != NULL) && vim_strchr(s + 1, *s) != NULL)
{ {
STRMOVE(s, s + 1); STRMOVE(s, s + 1);
--s; continue;
} }
} }
++s;
} }
} }

View File

@@ -13,6 +13,12 @@ function! Test_whichwrap()
set whichwrap+=h,l set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap) 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& set whichwrap&
endfunction endfunction

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
305,
/**/ /**/
304, 304,
/**/ /**/