diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-09-13 18:15:09 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-09-13 19:29:25 -0700 |
commit | 3344cffe7bf77c984550c01f9405f4d757150d8a (patch) | |
tree | e60810ef33fdd5f3f43f06d5ebc503d0e0594bd3 /src/nvim/diff.c | |
parent | 0a24a2c314a507108be754a0a2d2ed1a16ec523f (diff) | |
download | rneovim-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/diff.c')
-rw-r--r-- | src/nvim/diff.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 7328b88a40..db3ef7ac47 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2113,7 +2113,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_FILLER; } else if ((STRNCMP(p, "context:", 8) == 0) && ascii_isdigit(p[8])) { p += 8; - diff_context_new = getdigits_int(&p); + diff_context_new = getdigits_int(&p, false, diff_context_new); } else if (STRNCMP(p, "iblank", 6) == 0) { p += 6; diff_flags_new |= DIFF_IBLANK; @@ -2137,7 +2137,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_VERTICAL; } else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) { p += 11; - diff_foldcolumn_new = getdigits_int(&p); + diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new); } else if (STRNCMP(p, "hiddenoff", 9) == 0) { p += 9; diff_flags_new |= DIFF_HIDDEN_OFF; @@ -3000,10 +3000,10 @@ static int parse_diff_ed(char_u *line, // append: {first}a{first}[,{last}] // delete: {first}[,{last}]d{first} p = line; - f1 = getdigits(&p); + f1 = getdigits(&p, true, 0); if (*p == ',') { p++; - l1 = getdigits(&p); + l1 = getdigits(&p, true, 0); } else { l1 = f1; } @@ -3011,10 +3011,10 @@ static int parse_diff_ed(char_u *line, return FAIL; // invalid diff format } difftype = *p++; - f2 = getdigits(&p); + f2 = getdigits(&p, true, 0); if (*p == ',') { p++; - l2 = getdigits(&p); + l2 = getdigits(&p, true, 0); } else { l2 = f2; } @@ -3056,18 +3056,18 @@ static int parse_diff_unified(char_u *line, // @@ -oldline,oldcount +newline,newcount @@ p = line; if (*p++ == '@' && *p++ == '@' && *p++ == ' ' && *p++ == '-') { - oldline = getdigits(&p); + oldline = getdigits(&p, true, 0); if (*p == ',') { p++; - oldcount = getdigits(&p); + oldcount = getdigits(&p, true, 0); } else { oldcount = 1; } if (*p++ == ' ' && *p++ == '+') { - newline = getdigits(&p); + newline = getdigits(&p, true, 0); if (*p == ',') { p++; - newcount = getdigits(&p); + newcount = getdigits(&p, true, 0); } else { newcount = 1; } |