From: Bram Moolenaar Date: Sat, 9 May 2020 11:06:24 +0000 (+0200) Subject: patch 8.2.0718: gcc warning for returning pointer to local variable X-Git-Tag: v8.2.0718 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d3664df9008bd5f39f8a2555843d1b269946e4d;p=vim patch 8.2.0718: gcc warning for returning pointer to local variable Problem: Gcc warning for returning pointer to local variable. (John Marriott) Solution: Return another pointer. --- diff --git a/src/evalvars.c b/src/evalvars.c index 08b2990bc..0935bb3eb 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -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; } /* diff --git a/src/version.c b/src/version.c index ba81d6809..5c54b428e 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 718, /**/ 717, /**/