From 60b6e6f6cc60ac99253e1c13bd0cae4ef0e43201 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 28 Aug 2021 12:49:27 +0200 Subject: [PATCH] patch 8.2.3380: crash when using NULL string for funcref() Problem: Crash when using NULL string for funcref(). Solution: Check for NULL argument. (issue #8260) --- src/evalfunc.c | 5 +++++ src/testdir/test_expr.vim | 1 + src/version.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/evalfunc.c b/src/evalfunc.c index d6fb03ee4..287ca3c3f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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) { diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 597c02214..080eee7e1 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -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() diff --git a/src/version.c b/src/version.c index c2e07c668..e9a04e2ca 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3380, /**/ 3379, /**/ -- 2.50.1