diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2022-02-16 22:23:31 +0000 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2022-02-17 14:45:23 +0000 |
commit | 6890f8774bf6ec56b645c9b6389cdd1e4ed823ed (patch) | |
tree | b38cc91bd3abeaca930ce28a0101c6902d0c7254 /src/nvim/ops.c | |
parent | de8e2c61c1b273f57a5a2d85c474b4f12b1b8994 (diff) | |
download | rneovim-6890f8774bf6ec56b645c9b6389cdd1e4ed823ed.tar.gz rneovim-6890f8774bf6ec56b645c9b6389cdd1e4ed823ed.tar.bz2 rneovim-6890f8774bf6ec56b645c9b6389cdd1e4ed823ed.zip |
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.
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 8 |
1 files changed, 3 insertions, 5 deletions
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) { |