changeset 24494:c1de90bc6e63 v8.2.2787

patch 8.2.2787: MS-Windows: crash when using :echoconsole Commit: https://github.com/vim/vim/commit/6d4c1c7ba816294408097d72717366a97781655d Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 20 10:33:28 2021 +0200 patch 8.2.2787: MS-Windows: crash when using :echoconsole Problem: MS-Windows: crash when using :echoconsole. Solution: Do not write a NUL when it's already there.
author Bram Moolenaar <Bram@vim.org>
date Tue, 20 Apr 2021 10:45:04 +0200
parents 101d9c6be2d1
children 34bb8fd2da96
files src/os_win32.c src/version.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -6411,7 +6411,9 @@ mch_write(
 	return;
 # endif
 
-    s[len] = NUL;
+    // Avoid writing to a string literal.
+    if (s[len] != NUL)
+	s[len] = NUL;
 
     if (!term_console)
     {
@@ -6433,7 +6435,7 @@ mch_write(
 	    return;
 	}
 
-	while((ch = s[++prefix]))
+	while ((ch = s[++prefix]))
 	    if (ch <= 0x1e && !(ch != '\n' && ch != '\r' && ch != '\b'
 						&& ch != '\a' && ch != '\033'))
 		break;
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2787,
+/**/
     2786,
 /**/
     2785,