Mercurial > vim
diff src/eval.c @ 16706:77bcb5055fec v8.1.1355
patch 8.1.1355: obvious mistakes are accepted as valid expressions
commit https://github.com/vim/vim/commit/16e9b85113e0b354ece1cb4f5fcc7866850f3685
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 19 19:59:35 2019 +0200
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Problem: Obvious mistakes are accepted as valid expressions.
Solution: Be more strict about parsing numbers. (Yasuhiro Matsumoto,
closes #3981)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 May 2019 20:00:09 +0200 |
parents | a927fdf9a4b0 |
children | ef00b6bc186b |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -4453,7 +4453,13 @@ eval7( else { // decimal, hex or octal number - vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0); + vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0, TRUE); + if (len == 0) + { + semsg(_(e_invexpr2), *arg); + ret = FAIL; + break; + } *arg += len; if (evaluate) { @@ -7460,7 +7466,7 @@ tv_get_number_chk(typval_T *varp, int *d case VAR_STRING: if (varp->vval.v_string != NULL) vim_str2nr(varp->vval.v_string, NULL, NULL, - STR2NR_ALL, &n, NULL, 0); + STR2NR_ALL, &n, NULL, 0, FALSE); return n; case VAR_LIST: emsg(_("E745: Using a List as a Number"));