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)
diff --git a/src/option.c b/src/option.c
index 1237d04..32e97c9 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4954,7 +4954,7 @@
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 @@
/* Remove the duplicated value and
* the next comma. */
STRMOVE(s, s + 2);
- s -= 2;
+ continue;
}
}
else
@@ -4975,9 +4975,10 @@
&& vim_strchr(s + 1, *s) != NULL)
{
STRMOVE(s, s + 1);
- --s;
+ continue;
}
}
+ ++s;
}
}