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.
e551ccfb93

This approach is... interesting...

Tests fail.
This commit is contained in:
Sean Dewar 2022-02-16 22:23:31 +00:00
parent de8e2c61c1
commit 6890f8774b
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581

View File

@ -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) {