]> granicus.if.org Git - vim/commitdiff
patch 8.2.0718: gcc warning for returning pointer to local variable v8.2.0718
authorBram Moolenaar <Bram@vim.org>
Sat, 9 May 2020 11:06:24 +0000 (13:06 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 9 May 2020 11:06:24 +0000 (13:06 +0200)
Problem:    Gcc warning for returning pointer to local variable. (John
            Marriott)
Solution:   Return another pointer.

src/evalvars.c
src/version.c

index 08b2990bcc7077f69a7298525a2988262eb4a5a6..0935bb3ebc7d09e031bd135704b785d4d7ff988c 100644 (file)
@@ -2510,6 +2510,7 @@ lookup_scriptvar(char_u *name, size_t len, cctx_T *dummy UNUSED)
        return NULL;
     if (len < sizeof(buffer) - 1)
     {
+       // avoid an alloc/free for short names
        vim_strncpy(buffer, name, len);
        p = buffer;
     }
@@ -2529,7 +2530,8 @@ lookup_scriptvar(char_u *name, size_t len, cctx_T *dummy UNUSED)
 
     if (p != buffer)
        vim_free(p);
-    return res;
+    // Don't return "buffer", gcc complains.
+    return res == NULL ? NULL : IObuff;
 }
 
 /*
index ba81d6809277a749e0c46d37766264b06fa45287..5c54b428e54f4e6b2dbf5efd71047b12e3212567 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    718,
 /**/
     717,
 /**/