]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0682: Vim9: Segfault with uninitialized funcref v9.1.0682
authorErnie Rael <errael@raelity.com>
Mon, 19 Aug 2024 19:45:23 +0000 (21:45 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 19 Aug 2024 19:47:35 +0000 (21:47 +0200)
Problem:  Vim9: Segfault with uninitialized funcref
          (Daniel Viberg)
Solution: Check the Funcref for being Null before trying to access it
          (Ernie Rael)

fixes: #15523

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_func.vim
src/userfunc.c
src/version.c

index d07bbfba70705d5d371e25907ebb6f9f3ba4cb69..030ff833ef40c1a3f3a5507d280c2e8797cff60a 100644 (file)
@@ -164,6 +164,16 @@ def Test_wrong_function_name()
   END
   v9.CheckScriptFailure(lines, 'E1182:')
   delfunc g:Define
+
+  lines =<< trim END
+    vim9script
+    var F1_ref: func
+    def Start()
+      F1_ref()
+    enddef
+    Start()
+  END
+  v9.CheckScriptFailure(lines, 'E117:')
 enddef
 
 " Check that in a legacy script a :def accesses the correct script variables.
index 9a82394013a15e767a0383fe19f857e80bc8b8f4..5d167101d850b94372fba773df28bc0d1b4ea246 100644 (file)
@@ -2245,7 +2245,8 @@ find_func_imported(char_u *name, int flags)
            if (!HASHITEM_EMPTY(hi))
            {
                dictitem_T *di = HI2DI(hi);
-               if (di->di_tv.v_type == VAR_FUNC)
+               if (di->di_tv.v_type == VAR_FUNC
+                       && di->di_tv.vval.v_string != NULL)
                    func = find_func_even_dead(di->di_tv.vval.v_string, flags);
            }
        }
index 02b6d91dc670c3c40931cc3bdd6868503efc053f..c4472cf609b80eacd0a7f9aa83b740955f45befb 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    682,
 /**/
     681,
 /**/