From 6890f8774bf6ec56b645c9b6389cdd1e4ed823ed Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 16 Feb 2022 22:23:31 +0000 Subject: vim-patch:8.2.3575: overflow check still fails when sizeof(int) == sizeof(long) Problem: Overflow check still fails when sizeof(int) == sizeof(long). Solution: Use a float to check the result. https://github.com/vim/vim/commit/e551ccfb9311eea5252d1c3106ff7a53c762d994 This approach is... interesting... Tests fail. --- src/nvim/ops.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 8dc367d572..ea480c0b31 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3431,12 +3431,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) } do { - const long multlen = count * yanklen; + const double multlen = (double)count * (double)yanklen; - totlen = (size_t)(int)multlen; - if (count != 0 && yanklen != 0 - && (totlen != (size_t)multlen || (long)totlen / count != yanklen - || (long)totlen / yanklen != count)) { + totlen = (size_t)(int)(count * yanklen); + if ((double)totlen != multlen) { emsg(_(e_resulting_text_too_long)); break; } else if (totlen > 0) { -- cgit