forked from aniani/vim
patch 8.2.2793: MS-Windows: string literals are writable with MSVC
Problem: MS-Windows: string literals are writable with MSVC. Solution: Add the /GF compiler flag. Make mch_write() safer. (Ken Takata, closes #8133)
This commit is contained in:
@@ -6406,15 +6406,13 @@ mch_write(
|
||||
char_u *s,
|
||||
int len)
|
||||
{
|
||||
char_u *end = s + len;
|
||||
|
||||
# ifdef VIMDLL
|
||||
if (gui.in_use)
|
||||
return;
|
||||
# endif
|
||||
|
||||
// Avoid writing to a string literal.
|
||||
if (s[len] != NUL)
|
||||
s[len] = NUL;
|
||||
|
||||
if (!term_console)
|
||||
{
|
||||
write(1, s, (unsigned)len);
|
||||
@@ -6435,10 +6433,13 @@ mch_write(
|
||||
return;
|
||||
}
|
||||
|
||||
while ((ch = s[++prefix]))
|
||||
while (s + ++prefix < end)
|
||||
{
|
||||
ch = s[prefix];
|
||||
if (ch <= 0x1e && !(ch != '\n' && ch != '\r' && ch != '\b'
|
||||
&& ch != '\a' && ch != '\033'))
|
||||
break;
|
||||
}
|
||||
|
||||
if (p_wd)
|
||||
{
|
||||
|
Reference in New Issue
Block a user