mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	vim-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.
54598066ca
Co-authored-by: Bram Moolenaar <Bram@vim.org>
			
			
This commit is contained in:
		| @@ -467,12 +467,10 @@ char *deref_func_name(const char *name, int *lenp, partial_T **const partialp, b | ||||
| /// @param name function name | ||||
| void emsg_funcname(const char *errmsg, const char *name) | ||||
| { | ||||
|   char *p; | ||||
|   char *p = (char *)name; | ||||
|  | ||||
|   if ((uint8_t)(*name) == K_SPECIAL) { | ||||
|   if ((uint8_t)name[0] == K_SPECIAL && name[1] != NUL && name[2] != NUL) { | ||||
|     p = concat_str("<SNR>", name + 3); | ||||
|   } else { | ||||
|     p = (char *)name; | ||||
|   } | ||||
|  | ||||
|   semsg(_(errmsg), p); | ||||
| @@ -1863,8 +1861,7 @@ char *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, part | ||||
|  | ||||
|   // Check for hard coded <SNR>: already translated function ID (from a user | ||||
|   // command). | ||||
|   if ((unsigned char)(*pp)[0] == K_SPECIAL && (unsigned char)(*pp)[1] == KS_EXTRA | ||||
|       && (*pp)[2] == KE_SNR) { | ||||
|   if ((uint8_t)(*pp)[0] == K_SPECIAL && (uint8_t)(*pp)[1] == KS_EXTRA && (*pp)[2] == KE_SNR) { | ||||
|     *pp += 3; | ||||
|     len = get_id_len((const char **)pp) + 3; | ||||
|     return xmemdupz(start, (size_t)len); | ||||
| @@ -2232,6 +2229,10 @@ void ex_function(exarg_T *eap) | ||||
|     eap->skip = true; | ||||
|   } | ||||
|  | ||||
|   if (name == NULL) { | ||||
|     goto ret_free; | ||||
|   } | ||||
|  | ||||
|   // An error in a function call during evaluation of an expression in magic | ||||
|   // braces should not cause the function not to be defined. | ||||
|   saved_did_emsg = did_emsg; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 zeertzjq
					zeertzjq