vim-patch:8.0.0305 (#7265)

Problem:    Invalid memory access when option has duplicate flag.
Solution:   Correct pointer computation. (Dominique Pelle, closes vim/vim#1442)

aaaf57d8a9
This commit is contained in:
KunMing Xie 2017-09-18 01:43:45 +08:00 committed by Justin M. Keyes
parent 9d6bac3219
commit e53af2b1f5
3 changed files with 11 additions and 4 deletions

View File

@ -1749,7 +1749,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 P_ONECOMMA such as // if options have P_FLAGLIST and P_ONECOMMA such as
// 'whichwrap' // 'whichwrap'
if (flags & P_ONECOMMA) { if (flags & P_ONECOMMA) {
@ -1757,15 +1757,16 @@ do_set (
&& vim_strchr(s + 2, *s) != NULL) { && vim_strchr(s + 2, *s) != NULL) {
// Remove the duplicated value and the next comma. // Remove the duplicated value and the next comma.
STRMOVE(s, s + 2); STRMOVE(s, s + 2);
s -= 2; continue;
} }
} else { } else {
if ((!(flags & P_COMMA) || *s != ',') if ((!(flags & P_COMMA) || *s != ',')
&& 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

@ -647,7 +647,7 @@ static const int included_patches[] = {
308, 308,
307, 307,
// 306, // 306,
// 305, 305,
// 304, // 304,
// 303, // 303,
// 302, // 302,