patch 8.2.4065: computation overflow with large cound for :yank
Problem: Computation overflow with large cound for :yank.
Solution: Avoid an overflow.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 7134359..f16f600 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2374,7 +2374,10 @@
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.