]> granicus.if.org Git - vim/commitdiff
patch 8.2.1896: valgrind warns for using uninitialized memory v8.2.1896
authorBram Moolenaar <Bram@vim.org>
Sat, 24 Oct 2020 11:30:51 +0000 (13:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 24 Oct 2020 11:30:51 +0000 (13:30 +0200)
Problem:    Valgrind warns for using uninitialized memory.
Solution:   NUL terminate the SmcOpenConnection() error message. (Dominique
            PellĂ©, closes #7194)

src/os_unix.c
src/version.c

index 40df6b727cac24b89e95f264a3d99bd7542bfb24..27a88823f09a2a34dd6a3624dc00001c6c4850d3 100644 (file)
@@ -8068,10 +8068,13 @@ xsmp_init(void)
            errorstring);
     if (xsmp.smcconn == NULL)
     {
-       char errorreport[132];
-
        if (p_verbose > 0)
        {
+           char errorreport[132];
+
+           // If the message is too long it might not be NUL terminated.  Add
+           // a NUL at the end to make sure we don't go over the end.
+           errorstring[sizeof(errorstring) - 1] = NUL;
            vim_snprintf(errorreport, sizeof(errorreport),
                         _("XSMP SmcOpenConnection failed: %s"), errorstring);
            verb_msg(errorreport);
index e445117bcd1848a866ba3ddb19046142f4031a82..a1ee33e1ac8621412da13c5005b15aa9358e7c1a 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1896,
 /**/
     1895,
 /**/