Mercurial > vim
changeset 19609:fe827d6267c2 v8.2.0361
patch 8.2.0361: internal error when using "0" for a callback
Commit: https://github.com/vim/vim/commit/14e57909e662a43a42438e2701654af48af49b03
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 7 16:59:25 2020 +0100
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 https://github.com/vim/vim/issues/5743)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 07 Mar 2020 17:00:06 +0100 |
parents | 2f6e8d14ad36 |
children | 6eb401ee4b0c |
files | src/evalvars.c src/testdir/test_timers.vim src/version.c |
diffstat | 3 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -3643,7 +3643,8 @@ f_setbufvar(typval_T *argvars, typval_T 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;