aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/message.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-01-23 21:50:41 +0100
committerGitHub <noreply@github.com>2017-01-23 21:50:41 +0100
commit5892aab1b54b115cc3e74cb0ac59b0034627bf4e (patch)
tree974ccd5d14bb258403f3ec274ac93e8dfd651ca6 /src/nvim/message.c
parentd4b931deacf61528e902623d38d0f4d314bc1839 (diff)
parentb70a5cdd49ecd5f3fe749c1c66a169fee828c66e (diff)
downloadrneovim-5892aab1b54b115cc3e74cb0ac59b0034627bf4e.tar.gz
rneovim-5892aab1b54b115cc3e74cb0ac59b0034627bf4e.tar.bz2
rneovim-5892aab1b54b115cc3e74cb0ac59b0034627bf4e.zip
Merge #5996 from justinmk/coverity-133845
xstrlcat() + coverity fixes
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r--src/nvim/message.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 749fa8a706..91dd042777 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -381,20 +381,17 @@ static int other_sourcing_name(void)
return FALSE;
}
-/*
- * Get the message about the source, as used for an error message.
- * Returns an allocated string with room for one more character.
- * Returns NULL when no message is to be given.
- */
+/// Get the message about the source, as used for an error message.
+/// Returns an allocated string with room for one more character.
+/// Returns NULL when no message is to be given.
static char_u *get_emsg_source(void)
{
- char_u *Buf, *p;
-
if (sourcing_name != NULL && other_sourcing_name()) {
- p = (char_u *)_("Error detected while processing %s:");
- Buf = xmalloc(STRLEN(sourcing_name) + STRLEN(p));
- sprintf((char *)Buf, (char *)p, sourcing_name);
- return Buf;
+ char_u *p = (char_u *)_("Error detected while processing %s:");
+ size_t len = STRLEN(sourcing_name) + STRLEN(p) + 1;
+ char_u *buf = xmalloc(len);
+ snprintf((char *)buf, len, (char *)p, sourcing_name);
+ return buf;
}
return NULL;
}