0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0361: internal error when using "0" for a callback

Problem:    Internal error when using "0" for a callback.
Solution:   Give a normal error. (closes #5743)
This commit is contained in:
Bram Moolenaar
2020-03-07 16:59:25 +01:00
parent 8eab731328
commit 14e57909e6
3 changed files with 15 additions and 4 deletions

View File

@@ -3643,7 +3643,8 @@ f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED)
callback_T
get_callback(typval_T *arg)
{
callback_T res;
callback_T res;
int r = OK;
res.cb_free_name = FALSE;
if (arg->v_type == VAR_PARTIAL && arg->vval.v_partial != NULL)
@@ -3655,17 +3656,21 @@ get_callback(typval_T *arg)
else
{
res.cb_partial = NULL;
if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING)
if (arg->v_type == VAR_STRING && arg->vval.v_string != NULL
&& isdigit(*arg->vval.v_string))
r = FAIL;
else if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING)
{
// Note that we don't make a copy of the string.
res.cb_name = arg->vval.v_string;
func_ref(res.cb_name);
}
else if (arg->v_type == VAR_NUMBER && arg->vval.v_number == 0)
{
res.cb_name = (char_u *)"";
}
else
r = FAIL;
if (r == FAIL)
{
emsg(_("E921: Invalid callback argument"));
res.cb_name = NULL;

View File

@@ -422,4 +422,8 @@ func Test_timer_garbage_collect()
call timer_stop(timer)
endfunc
func Test_timer_invalid_callback()
call assert_fails('call timer_start(0, "0")', 'E921')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
361,
/**/
360,
/**/