summaryrefslogtreecommitdiff
path: root/src/testdir/test_marks.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-15 20:36:55 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-15 20:36:55 +0100
commitb3d33d8570bc49a7f90990572d7f9630a1bfae02 (patch)
tree46c3d7dedbb64129504f404d5dfdb2bfb7ec2ecc /src/testdir/test_marks.vim
parent1470dc35c4b14bda1995b7566c9a41a33eb06517 (diff)
downloadvim-git-b3d33d8570bc49a7f90990572d7f9630a1bfae02.tar.gz
patch 8.2.0120: virtcol() does not check arguments to be validv8.2.0120
Problem: virtcol() does not check arguments to be valid, which may lead to a crash. Solution: Check the column to be valid. Do not decrement MAXCOL. (closes #5480)
Diffstat (limited to 'src/testdir/test_marks.vim')
-rw-r--r--src/testdir/test_marks.vim21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim
index 3d04c70aa..829f40dcb 100644
--- a/src/testdir/test_marks.vim
+++ b/src/testdir/test_marks.vim
@@ -26,11 +26,11 @@ func Test_Incr_Marks()
endfunc
func Test_setpos()
- new one
+ new Xone
let onebuf = bufnr('%')
let onewin = win_getid()
call setline(1, ['aaa', 'bbb', 'ccc'])
- new two
+ new Xtwo
let twobuf = bufnr('%')
let twowin = win_getid()
call setline(1, ['aaa', 'bbb', 'ccc'])
@@ -63,7 +63,24 @@ func Test_setpos()
call setpos("'N", [onebuf, 1, 3, 0])
call assert_equal([onebuf, 1, 3, 0], getpos("'N"))
+ " try invalid column and check virtcol()
call win_gotoid(onewin)
+ call setpos("'a", [0, 1, 2, 0])
+ call assert_equal([0, 1, 2, 0], getpos("'a"))
+ call setpos("'a", [0, 1, -5, 0])
+ call assert_equal([0, 1, 2, 0], getpos("'a"))
+ call setpos("'a", [0, 1, 0, 0])
+ call assert_equal([0, 1, 1, 0], getpos("'a"))
+ call setpos("'a", [0, 1, 4, 0])
+ call assert_equal([0, 1, 4, 0], getpos("'a"))
+ call assert_equal(4, virtcol("'a"))
+ call setpos("'a", [0, 1, 5, 0])
+ call assert_equal([0, 1, 5, 0], getpos("'a"))
+ call assert_equal(4, virtcol("'a"))
+ call setpos("'a", [0, 1, 21341234, 0])
+ call assert_equal([0, 1, 21341234, 0], getpos("'a"))
+ call assert_equal(4, virtcol("'a"))
+
bwipe!
call win_gotoid(twowin)
bwipe!