changeset 9919:885e3c9c0e10 v7.4.2233

commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 21 14:36:15 2016 +0200 patch 7.4.2233 Problem: Crash when using funcref() with invalid name. (Dominique Pelle) Solution: Check for NULL translated name.
author Christian Brabandt <cb@256bit.org>
date Sun, 21 Aug 2016 14:45:05 +0200
parents 434585ac5cf2
children 81269a51ad2c
files src/evalfunc.c src/testdir/test_expr.vim src/version.c
diffstat 3 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3587,8 +3587,7 @@ common_function(typval_T *argvars, typva
 	use_string = TRUE;
     }
 
-    if (((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL)
-				   || is_funcref))
+    if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref)
     {
 	name = s;
 	trans_name = trans_function_name(&name, FALSE,
@@ -3597,7 +3596,8 @@ common_function(typval_T *argvars, typva
 	    s = NULL;
     }
 
-    if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s)))
+    if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s))
+					 || (is_funcref && trans_name == NULL))
 	EMSG2(_(e_invarg2), s);
     /* Don't check an autoload name for existence here. */
     else if (trans_name != NULL && (is_funcref
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -237,6 +237,7 @@ func Test_funcref()
   call assert_equal(1, OneByRef())
   let OneByRef = funcref('One')
   call assert_equal(2, OneByRef())
+  call assert_fails('echo funcref("{")', 'E475:')
 endfunc
 
 func Test_setmatches()
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2233,
+/**/
     2232,
 /**/
     2231,