changeset 25688:c07b6c54146a v8.2.3380

patch 8.2.3380: crash when using NULL string for funcref() Commit: https://github.com/vim/vim/commit/60b6e6f6cc60ac99253e1c13bd0cae4ef0e43201 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 28 12:49:27 2021 +0200 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 https://github.com/vim/vim/issues/8260)
author Bram Moolenaar <Bram@vim.org>
date Sat, 28 Aug 2021 13:00:04 +0200
parents dff7f4a5740c
children aa8b03b01457
files src/evalfunc.c src/testdir/test_expr.vim src/version.c
diffstat 3 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3932,6 +3932,11 @@ common_function(typval_T *argvars, typva
 	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)
     {
--- 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()
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3380,
+/**/
     3379,
 /**/
     3378,