diff options
author | KunMing Xie <qqzz014@gmail.com> | 2017-09-18 01:43:45 +0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-09-17 19:43:45 +0200 |
commit | e53af2b1f50c4662698f4a7c42a6008955a73426 (patch) | |
tree | ebe63dc9d1ce97554dbdcf3647447a8b82381cb2 | |
parent | 9d6bac3219a0cc1647b560b0d28b0a3fce9dc96a (diff) | |
download | rneovim-e53af2b1f50c4662698f4a7c42a6008955a73426.tar.gz rneovim-e53af2b1f50c4662698f4a7c42a6008955a73426.tar.bz2 rneovim-e53af2b1f50c4662698f4a7c42a6008955a73426.zip |
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)
https://github.com/vim/vim/commit/aaaf57d8a936efe420190c077e4a74041cc6c72e
-rw-r--r-- | src/nvim/option.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_options.vim | 6 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 8ba10fd38a..74250e83e6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1749,7 +1749,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' if (flags & P_ONECOMMA) { @@ -1757,15 +1757,16 @@ do_set ( && vim_strchr(s + 2, *s) != NULL) { // Remove the duplicated value and the next comma. STRMOVE(s, s + 2); - s -= 2; + continue; } } else { if ((!(flags & P_COMMA) || *s != ',') && vim_strchr(s + 1, *s) != NULL) { STRMOVE(s, s + 1); - s--; + continue; } } + s++; } } diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 5ee0919e18..2ffe63787b 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/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/nvim/version.c b/src/nvim/version.c index 6f38776a60..f5df256d3d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -647,7 +647,7 @@ static const int included_patches[] = { 308, 307, // 306, - // 305, + 305, // 304, // 303, // 302, |