vim-patch:7.4.2233

Problem:    Crash when using funcref() with invalid name. (Dominique Pelle)
Solution:   Check for NULL translated name.

843b884461
This commit is contained in:
Michael Ennen
2016-12-19 17:21:50 -07:00
parent 8cae66b5e0
commit effe760b13
3 changed files with 5 additions and 4 deletions

View File

@@ -10054,8 +10054,7 @@ static void common_function(typval_T *argvars, typval_T *rettv,
use_string = true; use_string = true;
} }
if (((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) if (((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref)) {
|| is_funcref)) {
name = s; name = s;
trans_name = trans_function_name(&name, false, trans_name = trans_function_name(&name, false,
TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD
@@ -10064,7 +10063,8 @@ static void common_function(typval_T *argvars, typval_T *rettv,
s = NULL; s = NULL;
} }
} }
if (s == NULL || *s == NUL || (use_string && ascii_isdigit(*s))) { if (s == NULL || *s == NUL || (use_string && ascii_isdigit(*s))
|| (is_funcref && trans_name == NULL)) {
EMSG2(_(e_invarg2), s); EMSG2(_(e_invarg2), s);
} else if (trans_name != NULL } else if (trans_name != NULL
&& (is_funcref ? find_func(trans_name) == NULL && (is_funcref ? find_func(trans_name) == NULL

View File

@@ -164,4 +164,5 @@ func Test_funcref()
call assert_equal(1, OneByRef()) call assert_equal(1, OneByRef())
let OneByRef = funcref('One') let OneByRef = funcref('One')
call assert_equal(2, OneByRef()) call assert_equal(2, OneByRef())
call assert_fails('echo funcref("{")', 'E475:')
endfunc endfunc

View File

@@ -207,7 +207,7 @@ static int included_patches[] = {
// 2236, // 2236,
// 2235, // 2235,
// 2234 NA // 2234 NA
// 2233, 2233,
// 2232 NA // 2232 NA
// 2231, // 2231,
// 2230, // 2230,