diff options
| author | Sean Dewar <seandewar@users.noreply.github.com> | 2022-02-16 22:37:10 +0000 |
|---|---|---|
| committer | Sean Dewar <seandewar@users.noreply.github.com> | 2022-02-17 17:06:16 +0000 |
| commit | 41d0e7af2097e0374ab16fb1567cf22d21aad180 (patch) | |
| tree | b50f5f45ef192da6608f8f6c963a50c0d1e96271 /src/nvim/testdir | |
| parent | 8170260bb35f3761d2008405289832b2620abc53 (diff) | |
| download | rneovim-41d0e7af2097e0374ab16fb1567cf22d21aad180.tar.gz rneovim-41d0e7af2097e0374ab16fb1567cf22d21aad180.tar.bz2 rneovim-41d0e7af2097e0374ab16fb1567cf22d21aad180.zip | |
vim-patch:8.2.3601: check for overflow in put count does not work well
Problem: Check for overflow in put count does not work well.
Solution: Improve the overflow check. (Ozaki Kiichi, closes vim/vim#9102)
https://github.com/vim/vim/commit/fa53722367c3793fda95dac665af74b8651065e9
Add some casts as Nvim uses size_t variables in some places.
We could technically adjust the logic to check for overflow outside of size_t's
range, but it's much easier to just port the patch exactly (also means we can
use the same tests).
v:sizeoflong is N/A, so convert the 64-bit tests to Lua and use the FFI to check
long's size.
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_put.vim | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim index a71224785a..9f2fc999a7 100644 --- a/src/nvim/testdir/test_put.vim +++ b/src/nvim/testdir/test_put.vim @@ -139,10 +139,18 @@ func Test_p_with_count_leaves_mark_at_end() endfunc func Test_very_large_count() - throw 'Skipped: v:sizeofint is N/A' + new + " total put-length (21474837 * 100) brings 32 bit int overflow + let @" = repeat('x', 100) + call assert_fails('norm 21474837p', 'E1240:') + bwipe! +endfunc + +func Test_very_large_count_64bit() + throw 'Skipped: v:sizeoflong is N/A' " use legacy/put_spec.lua instead - if v:sizeofint != 8 - throw 'Skipped: only works with 64 bit ints' + if v:sizeoflong < 8 + throw 'Skipped: only works with 64 bit long ints' endif new @@ -151,6 +159,29 @@ func Test_very_large_count() bwipe! endfunc +func Test_very_large_count_block() + new + " total put-length (21474837 * 100) brings 32 bit int overflow + call setline(1, repeat('x', 100)) + exe "norm \<C-V>99ly" + call assert_fails('norm 21474837p', 'E1240:') + bwipe! +endfunc + +func Test_very_large_count_block_64bit() + throw 'Skipped: v:sizeoflong is N/A' " use legacy/put_spec.lua instead + + if v:sizeoflong < 8 + throw 'Skipped: only works with 64 bit long ints' + endif + + new + call setline(1, 'x') + exe "norm \<C-V>y" + call assert_fails('norm 44444444444444p', 'E1240:') + bwipe! +endfunc + func Test_put_above_first_line() new let @" = 'text' |