changeset 26325:c189c40c9a22 v8.2.3693

patch 8.2.3693: Coverity warns for possibly using a NULL pointer Commit: https://github.com/vim/vim/commit/293eb9ba4669b1500370502397d399681e7098f0 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 29 10:36:19 2021 +0000 patch 8.2.3693: Coverity warns for possibly using a NULL pointer Problem: Coverity warns for possibly using a NULL pointer. Solution: Check for NULL and give an error.
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Nov 2021 11:45:03 +0100
parents a694e1ebf777
children 2a3b022339b0
files src/errors.h src/version.c src/vim9execute.c
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/errors.h
+++ b/src/errors.h
@@ -355,7 +355,8 @@ EXTERN char e_cannot_delete_vim9_script_
 	INIT(= N_("E1084: Cannot delete Vim9 script function %s"));
 EXTERN char e_not_callable_type_str[]
 	INIT(= N_("E1085: Not a callable type: %s"));
-// E1086 unused
+EXTERN char e_function_reference_invalid[]
+	INIT(= N_("E1086: Function reference invalid"));
 EXTERN char e_cannot_use_index_when_declaring_variable[]
 	INIT(= N_("E1087: Cannot use an index when declaring a variable"));
 // E1088 unused
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3693,
+/**/
     3692,
 /**/
     3691,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3189,6 +3189,12 @@ exec_instructions(ectx_T *ectx)
 		    {
 			ufunc = find_func(funcref->fr_func_name, FALSE, NULL);
 		    }
+		    if (ufunc == NULL)
+		    {
+			SOURCING_LNUM = iptr->isn_lnum;
+			emsg(_(e_function_reference_invalid));
+			goto theend;
+		    }
 		    if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL)
 			goto theend;
 		    tv = STACK_TV_BOT(0);