Mercurial > vim
comparison src/os_win32.c @ 24506:cf773d752eb9 v8.2.2793
patch 8.2.2793: MS-Windows: string literals are writable with MSVC
Commit: https://github.com/vim/vim/commit/d23f8bde5cd16b7752cc4a73da106673839ed824
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 21 11:30:48 2021 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 21 Apr 2021 11:45:04 +0200 |
parents | c1de90bc6e63 |
children | 30ad18017e1c |
comparison
equal
deleted
inserted
replaced
24505:b68e47dd5919 | 24506:cf773d752eb9 |
---|---|
6404 void | 6404 void |
6405 mch_write( | 6405 mch_write( |
6406 char_u *s, | 6406 char_u *s, |
6407 int len) | 6407 int len) |
6408 { | 6408 { |
6409 char_u *end = s + len; | |
6410 | |
6409 # ifdef VIMDLL | 6411 # ifdef VIMDLL |
6410 if (gui.in_use) | 6412 if (gui.in_use) |
6411 return; | 6413 return; |
6412 # endif | 6414 # endif |
6413 | 6415 |
6414 // Avoid writing to a string literal. | |
6415 if (s[len] != NUL) | |
6416 s[len] = NUL; | |
6417 | |
6418 if (!term_console) | 6416 if (!term_console) |
6419 { | 6417 { |
6420 write(1, s, (unsigned)len); | 6418 write(1, s, (unsigned)len); |
6421 return; | 6419 return; |
6422 } | 6420 } |
6433 { | 6431 { |
6434 redraw_all_later(CLEAR); | 6432 redraw_all_later(CLEAR); |
6435 return; | 6433 return; |
6436 } | 6434 } |
6437 | 6435 |
6438 while ((ch = s[++prefix])) | 6436 while (s + ++prefix < end) |
6437 { | |
6438 ch = s[prefix]; | |
6439 if (ch <= 0x1e && !(ch != '\n' && ch != '\r' && ch != '\b' | 6439 if (ch <= 0x1e && !(ch != '\n' && ch != '\r' && ch != '\b' |
6440 && ch != '\a' && ch != '\033')) | 6440 && ch != '\a' && ch != '\033')) |
6441 break; | 6441 break; |
6442 } | |
6442 | 6443 |
6443 if (p_wd) | 6444 if (p_wd) |
6444 { | 6445 { |
6445 WaitForChar(p_wd, FALSE); | 6446 WaitForChar(p_wd, FALSE); |
6446 if (prefix != 0) | 6447 if (prefix != 0) |