comparison src/option.c @ 10831:e926c5a7f9bf v8.0.0305

patch 8.0.0305: invalid memory access when option has duplicate flag commit https://github.com/vim/vim/commit/aaaf57d8a936efe420190c077e4a74041cc6c72e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 5 14:13:20 2017 +0100 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 https://github.com/vim/vim/issues/1442)
author Christian Brabandt <cb@256bit.org>
date Sun, 05 Feb 2017 14:15:04 +0100
parents 4dea7c96fc82
children 40939b171432
comparison
equal deleted inserted replaced
10830:fe0e00dab982 10831:e926c5a7f9bf
4952 } 4952 }
4953 4953
4954 if (flags & P_FLAGLIST) 4954 if (flags & P_FLAGLIST)
4955 { 4955 {
4956 /* Remove flags that appear twice. */ 4956 /* Remove flags that appear twice. */
4957 for (s = newval; *s; ++s) 4957 for (s = newval; *s;)
4958 { 4958 {
4959 /* if options have P_FLAGLIST and 4959 /* if options have P_FLAGLIST and
4960 * P_ONECOMMA such as 'whichwrap' */ 4960 * P_ONECOMMA such as 'whichwrap' */
4961 if (flags & P_ONECOMMA) 4961 if (flags & P_ONECOMMA)
4962 { 4962 {
4964 && vim_strchr(s + 2, *s) != NULL) 4964 && vim_strchr(s + 2, *s) != NULL)
4965 { 4965 {
4966 /* Remove the duplicated value and 4966 /* Remove the duplicated value and
4967 * the next comma. */ 4967 * the next comma. */
4968 STRMOVE(s, s + 2); 4968 STRMOVE(s, s + 2);
4969 s -= 2; 4969 continue;
4970 } 4970 }
4971 } 4971 }
4972 else 4972 else
4973 { 4973 {
4974 if ((!(flags & P_COMMA) || *s != ',') 4974 if ((!(flags & P_COMMA) || *s != ',')
4975 && vim_strchr(s + 1, *s) != NULL) 4975 && vim_strchr(s + 1, *s) != NULL)
4976 { 4976 {
4977 STRMOVE(s, s + 1); 4977 STRMOVE(s, s + 1);
4978 --s; 4978 continue;
4979 } 4979 }
4980 } 4980 }
4981 ++s;
4981 } 4982 }
4982 } 4983 }
4983 4984
4984 if (save_arg != NULL) /* number for 'whichwrap' */ 4985 if (save_arg != NULL) /* number for 'whichwrap' */
4985 arg = save_arg; 4986 arg = save_arg;