summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-13 12:05:09 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-13 12:05:09 +0000
commit54598066ca4cfaf0761aedf47e4ba9844674791e (patch)
tree3b200bd6b03d4ba4b4e1cc035599cad8142cdd82
parentd041f4208b0a2149e9d41f6443aa1c14c076a411 (diff)
downloadvim-git-54598066ca4cfaf0761aedf47e4ba9844674791e.tar.gz
patch 8.2.4073: Coverity warns for using NULL pointerv8.2.4073
Problem: Coverity warns for using NULL pointer. Solution: Bail out when running out of memory. Check for running over end of a string.
-rw-r--r--src/userfunc.c8
-rw-r--r--src/version.c2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index a227700dc..4072349cb 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1674,12 +1674,10 @@ deref_func_name(
void
emsg_funcname(char *ermsg, char_u *name)
{
- char_u *p;
+ char_u *p = name;
- if (*name == K_SPECIAL)
+ if (name[0] == K_SPECIAL && name[1] != NUL && name[2] != NUL)
p = concat_str((char_u *)"<SNR>", name + 3);
- else
- p = name;
semsg(_(ermsg), p);
if (p != name)
vim_free(p);
@@ -4154,6 +4152,8 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
else
eap->skip = TRUE;
}
+ if (name == NULL)
+ goto ret_free; // out of memory
// For "export def FuncName()" in an autoload script the function name
// is stored with the legacy autoload name "dir#script#FuncName" so
diff --git a/src/version.c b/src/version.c
index 12097729f..1b37a5d50 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4073,
+/**/
4072,
/**/
4071,