diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-03-07 23:15:25 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-03-07 23:37:27 -0500 |
commit | b00650cfe909313e58aa8181474d7f016d9df94a (patch) | |
tree | e436abc7dab365b52a2385af6fabe5516907c773 /src | |
parent | 1ad414f6ee9eea0f138c8e03c09a6f572b5ddc69 (diff) | |
download | rneovim-b00650cfe909313e58aa8181474d7f016d9df94a.tar.gz rneovim-b00650cfe909313e58aa8181474d7f016d9df94a.tar.bz2 rneovim-b00650cfe909313e58aa8181474d7f016d9df94a.zip |
vim-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 vim/vim#5743)
https://github.com/vim/vim/commit/14e57909e662a43a42438e2701654af48af49b03
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test_timers.vim | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f5c5ef9e97..ca0e078e4a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8114,10 +8114,16 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool callback_from_typval(Callback *const callback, typval_T *const arg) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { + int r = OK; + if (arg->v_type == VAR_PARTIAL && arg->vval.v_partial != NULL) { callback->data.partial = arg->vval.v_partial; callback->data.partial->pt_refcount++; callback->type = kCallbackPartial; + } else if (arg->v_type == VAR_STRING + && arg->vval.v_string != NULL + && ascii_isdigit(*arg->vval.v_string)) { + r = FAIL; } else if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING) { char_u *name = arg->vval.v_string; func_ref(name); @@ -8126,6 +8132,10 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg) } else if (arg->v_type == VAR_NUMBER && arg->vval.v_number == 0) { callback->type = kCallbackNone; } else { + r = FAIL; + } + + if (r == FAIL) { EMSG(_("E921: Invalid callback argument")); return false; } diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 3043103270..40376a877e 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -339,4 +339,8 @@ func Test_nocatch_garbage_collect() delfunc FeedChar endfunc +func Test_timer_invalid_callback() + call assert_fails('call timer_start(0, "0")', 'E921') +endfunc + " vim: shiftwidth=2 sts=2 expandtab |