aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spellfile.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-13 18:15:09 -0700
committerJustin M. Keyes <justinkz@gmail.com>2019-09-13 19:29:25 -0700
commit3344cffe7bf77c984550c01f9405f4d757150d8a (patch)
treee60810ef33fdd5f3f43f06d5ebc503d0e0594bd3 /src/nvim/spellfile.c
parent0a24a2c314a507108be754a0a2d2ed1a16ec523f (diff)
downloadrneovim-3344cffe7bf77c984550c01f9405f4d757150d8a.tar.gz
rneovim-3344cffe7bf77c984550c01f9405f4d757150d8a.tar.bz2
rneovim-3344cffe7bf77c984550c01f9405f4d757150d8a.zip
getdigits: introduce `strict`, `def` parameters
Problem: During a refactor long ago, we changed the `getdigits_*` familiy of functions to abort on overflow. But this is often wrong, because many of these codepaths are handling user input. Solution: Decide at each call-site whether to use "strict" mode. fix #5555
Diffstat (limited to 'src/nvim/spellfile.c')
-rw-r--r--src/nvim/spellfile.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 405e390589..c6b5dc500d 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -1833,19 +1833,19 @@ int spell_check_msm(void)
if (!ascii_isdigit(*p))
return FAIL;
// block count = (value * 1024) / SBLOCKSIZE (but avoid overflow)
- start = (getdigits_long(&p) * 10) / (SBLOCKSIZE / 102);
+ start = (getdigits_long(&p, true, 0) * 10) / (SBLOCKSIZE / 102);
if (*p != ',')
return FAIL;
++p;
if (!ascii_isdigit(*p))
return FAIL;
- incr = (getdigits_long(&p) * 102) / (SBLOCKSIZE / 10);
+ incr = (getdigits_long(&p, true, 0) * 102) / (SBLOCKSIZE / 10);
if (*p != ',')
return FAIL;
++p;
if (!ascii_isdigit(*p))
return FAIL;
- added = getdigits_long(&p) * 1024;
+ added = getdigits_long(&p, true, 0) * 1024;
if (*p != NUL)
return FAIL;
@@ -2787,7 +2787,7 @@ static unsigned get_affitem(int flagtype, char_u **pp)
++*pp; // always advance, avoid getting stuck
return 0;
}
- res = getdigits_int(pp);
+ res = getdigits_int(pp, true, 0);
} else {
res = mb_ptr2char_adv((const char_u **)pp);
if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
@@ -2906,7 +2906,7 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
case AFT_NUM:
for (p = afflist; *p != NUL; ) {
- int digits = getdigits_int(&p);
+ int digits = getdigits_int(&p, true, 0);
assert(digits >= 0);
n = (unsigned int)digits;
if (n == flag)