# HG changeset patch # User Bram Moolenaar # Date 1641930302 -3600 # Node ID 0878d7c64140cd6e24150e03427a41405be37f77 # Parent 04adc77bb4b899e66a80d89a67fcc1ab7cbc0a35 patch 8.2.4065: computation overflow with large cound for :yank Commit: https://github.com/vim/vim/commit/3cf21b305104e91a28e4ce3a473672b2e88a9469 Author: Bram Moolenaar Date: Tue Jan 11 19:34:16 2022 +0000 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 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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. diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim --- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -704,9 +704,14 @@ func Test_address_line_overflow() throw 'Skipped: only works with 64 bit long ints' endif new - call setline(1, 'text') + call setline(1, range(100)) call assert_fails('|.44444444444444444444444', 'E1247:') call assert_fails('|.9223372036854775806', 'E1247:') + + $ + yank 77777777777777777777 + call assert_equal("99\n", @") + bwipe! endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4065, +/**/ 4064, /**/ 4063,