aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2016-01-21 16:17:57 +0100
committeroni-link <knil.ino@gmail.com>2016-01-21 16:37:58 +0100
commitf2558890f54722ab31b1e073e9ce844750cd200a (patch)
treee09cff3f0e3506d2baeaacfa9739c55c74ac5d5e
parent7a8e41e8ee56a1fcec07f85566022548d41a944a (diff)
downloadrneovim-f2558890f54722ab31b1e073e9ce844750cd200a.tar.gz
rneovim-f2558890f54722ab31b1e073e9ce844750cd200a.tar.bz2
rneovim-f2558890f54722ab31b1e073e9ce844750cd200a.zip
coverity/133858: Out-of-bounds access
Allocating insufficient memory for the terminating NUL of the string. False positive, we allocating more memory than we need.
-rw-r--r--src/nvim/if_cscope.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index af3a87211a..476dcc9478 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -1661,6 +1661,8 @@ static void cs_print_tags_priv(char **matches, char **cntxts,
// NUL terminate tag string in matches[0].
*ptag_end = NUL;
+ // The "%s" in cstag_msg won't appear in the result string, so we don't need
+ // extra memory for terminating NUL.
size_t newsize = strlen(cstag_msg) + (size_t)(ptag_end - ptag);
char *buf = xmalloc(newsize);
size_t bufsize = newsize; // Track available bufsize