diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-07-27 22:00:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-27 22:00:44 +0200 |
commit | 4490ec4e839e45a2e6923c265c7e9e64c240b805 (patch) | |
tree | 3ef2dc127890ac6a644f38ae7932b7e70071544a /src/cmdhist.c | |
parent | 5d7c2df536c17db4a9c61e0760bdcf78d0db7330 (diff) |
patch 8.2.3229: Vim9: runtime and compile time type checks are not the samev8.2.3229
Problem: Vim9: runtime and compile time type checks are not the same.
Solution: Add more runtime type checks for builtin functions. (Yegappan
Lakshmanan, closes #8646)
Diffstat (limited to 'src/cmdhist.c')
-rw-r--r-- | src/cmdhist.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmdhist.c b/src/cmdhist.c index f3b8b007eb..0ac3ff6949 100644 --- a/src/cmdhist.c +++ b/src/cmdhist.c @@ -545,6 +545,12 @@ f_histadd(typval_T *argvars UNUSED, typval_T *rettv) rettv->vval.v_number = FALSE; if (check_secure()) return; + + if (in_vim9script() + && (check_for_string_arg(argvars, 0) == FAIL + || check_for_string_arg(argvars, 1) == FAIL)) + return; + str = tv_get_string_chk(&argvars[0]); // NULL on type error histype = str != NULL ? get_histtype(str) : -1; if (histype >= 0) @@ -630,9 +636,12 @@ f_histget(typval_T *argvars UNUSED, typval_T *rettv) f_histnr(typval_T *argvars UNUSED, typval_T *rettv) { int i; + char_u *histname; - char_u *histname = tv_get_string_chk(&argvars[0]); + if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) + return; + histname = tv_get_string_chk(&argvars[0]); i = histname == NULL ? HIST_CMD - 1 : get_histtype(histname); if (i >= HIST_CMD && i < HIST_COUNT) i = get_history_idx(i); |