Skip to content

Commit 843b884

Browse files
committed
patch 7.4.2233
Problem: Crash when using funcref() with invalid name. (Dominique Pelle) Solution: Check for NULL translated name.
1 parent e07e797 commit 843b884

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/evalfunc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,8 +3587,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
35873587
use_string = TRUE;
35883588
}
35893589

3590-
if (((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL)
3591-
|| is_funcref))
3590+
if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref)
35923591
{
35933592
name = s;
35943593
trans_name = trans_function_name(&name, FALSE,
@@ -3597,7 +3596,8 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
35973596
s = NULL;
35983597
}
35993598

3600-
if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s)))
3599+
if (s == NULL || *s == NUL || (use_string && VIM_ISDIGIT(*s))
3600+
|| (is_funcref && trans_name == NULL))
36013601
EMSG2(_(e_invarg2), s);
36023602
/* Don't check an autoload name for existence here. */
36033603
else if (trans_name != NULL && (is_funcref

src/testdir/test_expr.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func Test_funcref()
237237
call assert_equal(1, OneByRef())
238238
let OneByRef = funcref('One')
239239
call assert_equal(2, OneByRef())
240+
call assert_fails('echo funcref("{")', 'E475:')
240241
endfunc
241242

242243
func Test_setmatches()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2233,
766768
/**/
767769
2232,
768770
/**/

0 commit comments

Comments
 (0)