From 3344cffe7bf77c984550c01f9405f4d757150d8a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 13 Sep 2019 18:15:09 -0700 Subject: 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 --- src/nvim/cursor_shape.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/nvim/cursor_shape.c') diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 9c8128db4f..3b39b1cf21 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -176,15 +176,17 @@ char_u *parse_shape_opt(int what) p += len; if (!ascii_isdigit(*p)) return (char_u *)N_("E548: digit expected"); - int n = getdigits_int(&p); + int n = getdigits_int(&p, false, 0); if (len == 3) { /* "ver" or "hor" */ - if (n == 0) + if (n == 0) { return (char_u *)N_("E549: Illegal percentage"); + } if (round == 2) { - if (TOLOWER_ASC(i) == 'v') + if (TOLOWER_ASC(i) == 'v') { shape_table[idx].shape = SHAPE_VER; - else + } else { shape_table[idx].shape = SHAPE_HOR; + } shape_table[idx].percentage = n; } } else if (round == 2) { -- cgit From 6aae0e7c943267d2109ae20ec5086791c3b94a5e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 13 Sep 2019 18:51:13 -0700 Subject: lint --- src/nvim/cursor_shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/cursor_shape.c') diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 3b39b1cf21..3f06340611 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -177,7 +177,7 @@ char_u *parse_shape_opt(int what) if (!ascii_isdigit(*p)) return (char_u *)N_("E548: digit expected"); int n = getdigits_int(&p, false, 0); - if (len == 3) { /* "ver" or "hor" */ + if (len == 3) { // "ver" or "hor" if (n == 0) { return (char_u *)N_("E549: Illegal percentage"); } -- cgit