1
0
forked from aniani/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.
This commit is contained in:
Bram Moolenaar
2020-05-09 13:06:24 +02:00
parent 7d131b0715
commit 7d3664df90
2 changed files with 5 additions and 1 deletions

View 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;
}
/*