Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
27087:e8f812ec5879 | 27088:3956e3bb47ec |
---|---|
1672 * "ermsg" is to be passed without translation, use N_() instead of _(). | 1672 * "ermsg" is to be passed without translation, use N_() instead of _(). |
1673 */ | 1673 */ |
1674 void | 1674 void |
1675 emsg_funcname(char *ermsg, char_u *name) | 1675 emsg_funcname(char *ermsg, char_u *name) |
1676 { | 1676 { |
1677 char_u *p; | 1677 char_u *p = name; |
1678 | 1678 |
1679 if (*name == K_SPECIAL) | 1679 if (name[0] == K_SPECIAL && name[1] != NUL && name[2] != NUL) |
1680 p = concat_str((char_u *)"<SNR>", name + 3); | 1680 p = concat_str((char_u *)"<SNR>", name + 3); |
1681 else | |
1682 p = name; | |
1683 semsg(_(ermsg), p); | 1681 semsg(_(ermsg), p); |
1684 if (p != name) | 1682 if (p != name) |
1685 vim_free(p); | 1683 vim_free(p); |
1686 } | 1684 } |
1687 | 1685 |
4152 return NULL; | 4150 return NULL; |
4153 } | 4151 } |
4154 else | 4152 else |
4155 eap->skip = TRUE; | 4153 eap->skip = TRUE; |
4156 } | 4154 } |
4155 if (name == NULL) | |
4156 goto ret_free; // out of memory | |
4157 | 4157 |
4158 // For "export def FuncName()" in an autoload script the function name | 4158 // For "export def FuncName()" in an autoload script the function name |
4159 // is stored with the legacy autoload name "dir#script#FuncName" so | 4159 // is stored with the legacy autoload name "dir#script#FuncName" so |
4160 // that it can also be found in legacy script. | 4160 // that it can also be found in legacy script. |
4161 if (is_export) | 4161 if (is_export) |