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 08b2990..0935bb3 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2510,6 +2510,7 @@
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 @@
if (p != buffer)
vim_free(p);
- return res;
+ // Don't return "buffer", gcc complains.
+ return res == NULL ? NULL : IObuff;
}
/*