Skip to content

Commit

Permalink
patch 8.2.4073: Coverity warns for using NULL pointer
Browse files Browse the repository at this point in the history
Problem:    Coverity warns for using NULL pointer.
Solution:   Bail out when running out of memory. Check for running over end of
            a string.
  • Loading branch information
brammool committed Jan 13, 2022
1 parent d041f42 commit 5459806
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/userfunc.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4073,
/**/
4072,
/**/
Expand Down

0 comments on commit 5459806

Please sign in to comment.