0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4065: computation overflow with large cound for :yank

Problem:    Computation overflow with large cound for :yank.
Solution:   Avoid an overflow.
This commit is contained in:
Bram Moolenaar
2022-01-11 19:34:16 +00:00
parent 2284f6cca3
commit 3cf21b3051
3 changed files with 12 additions and 2 deletions

View File

@@ -2374,7 +2374,10 @@ do_one_cmd(
else
{
ea.line1 = ea.line2;
ea.line2 += n - 1;
if (ea.line2 >= LONG_MAX - (n - 1))
ea.line2 = LONG_MAX; // avoid overflow
else
ea.line2 += n - 1;
++ea.addr_count;
/*
* Be vi compatible: no error message for out of range.