summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-07 16:59:25 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-07 16:59:25 +0100
commit14e57909e662a43a42438e2701654af48af49b03 (patch)
tree1c613eeeff3d485e32047df43c24f6da708769d1
parent8eab73132838e977092d7b46f70b4ecf6274fd6a (diff)
downloadvim-git-14e57909e662a43a42438e2701654af48af49b03.tar.gz
patch 8.2.0361: internal error when using "0" for a callbackv8.2.0361
Problem: Internal error when using "0" for a callback. Solution: Give a normal error. (closes #5743)
-rw-r--r--src/evalvars.c13
-rw-r--r--src/testdir/test_timers.vim4
-rw-r--r--src/version.c2
3 files changed, 15 insertions, 4 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 227253e1f..40a22f690 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -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;
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index 37af18c38..1a6391b9d 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 608532006..2c4cd0db3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 361,
+/**/
360,
/**/
359,