Mercurial > vim
diff src/userfunc.c @ 27088:3956e3bb47ec v8.2.4073
patch 8.2.4073: Coverity warns for using NULL pointer
Commit: https://github.com/vim/vim/commit/54598066ca4cfaf0761aedf47e4ba9844674791e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 13 12:05:09 2022 +0000
patch 8.2.4073: Coverity warns for using NULL pointer
Problem: Coverity warns for using NULL pointer.
Solution: Bail out when running out of memory. Check for running over end of
a string.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Jan 2022 13:15:04 +0100 |
parents | ceff6a546748 |
children | 6d063974af23 |
line wrap: on
line diff
--- 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; - - if (*name == K_SPECIAL) + char_u *p = name; + + 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 *na 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