]> granicus.if.org Git - vim/commitdiff
patch 8.2.2787: MS-Windows: crash when using :echoconsole v8.2.2787
authorBram Moolenaar <Bram@vim.org>
Tue, 20 Apr 2021 08:33:28 +0000 (10:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 20 Apr 2021 08:33:28 +0000 (10:33 +0200)
Problem:    MS-Windows: crash when using :echoconsole.
Solution:   Do not write a NUL when it's already there.

src/os_win32.c
src/version.c

index 7c2051f7f3971756dd4ae10332a847a0139dbbf0..9b692ec0e9c55d2378e620b8d05a27866f3064e3 100644 (file)
@@ -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;
index 834196d83b82da8e6d538895aa253c679d7914dc..54bf127614cd4fcff3e1a405e324ab401df151c2 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2787,
 /**/
     2786,
 /**/