]> granicus.if.org Git - vim/commitdiff
patch 8.2.1785: compiler warning for strcp() out of bounds v8.2.1785
authorBram Moolenaar <Bram@vim.org>
Fri, 2 Oct 2020 16:11:56 +0000 (18:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 2 Oct 2020 16:11:56 +0000 (18:11 +0200)
Problem:    Compiler warning for strcp() out of bounds. (Christian Brabandt)
Solution:   use memmove() instead.

src/dict.c
src/version.c

index 05281cb70d8cf7f46f689f440c4b4c01b27dcf5b..5725140df31cbba78b0680873e1d7ce60282cc7b 100644 (file)
@@ -236,11 +236,12 @@ dictitem_alloc(char_u *key)
 dictitem_copy(dictitem_T *org)
 {
     dictitem_T *di;
+    size_t     len = STRLEN(org->di_key);
 
-    di = alloc(offsetof(dictitem_T, di_key) + STRLEN(org->di_key) + 1);
+    di = alloc(offsetof(dictitem_T, di_key) + len + 1);
     if (di != NULL)
     {
-       STRCPY(di->di_key, org->di_key);
+       mch_memmove(di->di_key, org->di_key, len + 1);
        di->di_flags = DI_FLAGS_ALLOC;
        copy_tv(&org->di_tv, &di->di_tv);
     }
index 31e8359029b5a1699008a2ff0d595feeae15a02f..8f0fac9b834b45ab547a57f4cd9791d4e714921d 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1785,
 /**/
     1784,
 /**/