]> granicus.if.org Git - vim/commitdiff
patch 8.2.3380: crash when using NULL string for funcref() v8.2.3380
authorBram Moolenaar <Bram@vim.org>
Sat, 28 Aug 2021 10:49:27 +0000 (12:49 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 28 Aug 2021 10:49:27 +0000 (12:49 +0200)
Problem:    Crash when using NULL string for funcref().
Solution:   Check for NULL argument. (issue #8260)

src/evalfunc.c
src/testdir/test_expr.vim
src/version.c

index d6fb03ee40a78c146c240babae858ff7da935bd3..287ca3c3ff322739d67a3ac0a5d1ba9d3a910115 100644 (file)
@@ -3932,6 +3932,11 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
        s = tv_get_string(&argvars[0]);
        use_string = TRUE;
     }
+    if (s == NULL)
+    {
+       semsg(_(e_invarg2), "NULL");
+       return;
+    }
 
     if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref)
     {
index 597c0221456065a3f02c24b622b37ac04183a981..080eee7e10a773778361c77e7d0271d84bd617ca 100644 (file)
@@ -501,6 +501,7 @@ func Test_funcref()
   let OneByRef = funcref("One", repeat(["foo"], 20))
   call assert_fails('let OneByRef = funcref("One", repeat(["foo"], 21))', 'E118:')
   call assert_fails('echo function("min") =~ function("min")', 'E694:')
+  call assert_fails('echo test_null_function()->funcref()', 'E475: Invalid argument: NULL')
 endfunc
 
 func Test_setmatches()
index c2e07c668f62a9ad55aa6f4e92b4f9d6a4c991f5..e9a04e2ca882688b29ba331eea5ce9ef8b2de0d7 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3380,
 /**/
     3379,
 /**/