diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-09 13:06:24 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-09 13:06:24 +0200 |
commit | 7d3664df9008bd5f39f8a2555843d1b269946e4d (patch) | |
tree | e2566a0619969a3c98d159a124e4df3fec2627c5 /src/evalvars.c | |
parent | 7d131b071539e73e4f8a1e6ffbb4d7bfc69a57ec (diff) | |
download | vim-git-7d3664df9008bd5f39f8a2555843d1b269946e4d.tar.gz |
patch 8.2.0718: gcc warning for returning pointer to local variablev8.2.0718
Problem: Gcc warning for returning pointer to local variable. (John
Marriott)
Solution: Return another pointer.
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; } /* |