Mercurial > vim
diff src/typval.c @ 24246:35603c7991d7 v8.2.2664
patch 8.2.2664: Vim9: not enough function arguments checked for string
Commit: https://github.com/vim/vim/commit/32105ae88f3aa6a6af30336f0bc9f8eb81292cd7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 27 18:59:25 2021 +0100
patch 8.2.2664: Vim9: not enough function arguments checked for string
Problem: Vim9: not enough function arguments checked for string.
Solution: Check in balloon functions. Refactor function arguments.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Mar 2021 19:00:04 +0100 |
parents | 083f07f99e20 |
children | 8b4159943d9a |
line wrap: on
line diff
--- a/src/typval.c +++ b/src/typval.c @@ -344,12 +344,12 @@ tv_get_float(typval_T *varp) * Give an error and return FAIL unless "tv" is a string. */ int -check_for_string(typval_T *tv, int arg) +check_for_string_arg(typval_T *args, int idx) { - if (tv->v_type != VAR_STRING) + if (args[idx].v_type != VAR_STRING) { - if (arg > 0) - semsg(_(e_string_required_for_argument_nr), arg); + if (idx >= 0) + semsg(_(e_string_required_for_argument_nr), idx + 1); else emsg(_(e_stringreq)); return FAIL; @@ -358,17 +358,17 @@ check_for_string(typval_T *tv, int arg) } /* - * Give an error and return FAIL unless "tv" is a non-empty string. + * Give an error and return FAIL unless "args[idx]" is a non-empty string. */ int -check_for_nonempty_string(typval_T *tv, int arg) +check_for_nonempty_string_arg(typval_T *args, int idx) { - if (check_for_string(tv, arg) == FAIL) + if (check_for_string_arg(args, idx) == FAIL) return FAIL; - if (tv->vval.v_string == NULL || *tv->vval.v_string == NUL) + if (args[idx].vval.v_string == NULL || *args[idx].vval.v_string == NUL) { - if (arg > 0) - semsg(_(e_non_empty_string_required_for_argument_nr), arg); + if (idx >= 0) + semsg(_(e_non_empty_string_required_for_argument_nr), idx + 1); else emsg(_(e_non_empty_string_required)); return FAIL;