Mercurial > vim
comparison src/testdir/test_marks.vim @ 19121:a51fee786930 v8.2.0120
patch 8.2.0120: virtcol() does not check arguments to be valid
Commit: https://github.com/vim/vim/commit/b3d33d8570bc49a7f90990572d7f9630a1bfae02
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 15 20:36:55 2020 +0100
patch 8.2.0120: virtcol() does not check arguments to be valid
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 15 Jan 2020 20:45:04 +0100 |
parents | de2d1820215a |
children | 2f4be7ca1b1b |
comparison
equal
deleted
inserted
replaced
19120:0e5a3e183199 | 19121:a51fee786930 |
---|---|
24 call assert_equal("XXX 123 123", getline(3)) | 24 call assert_equal("XXX 123 123", getline(3)) |
25 enew! | 25 enew! |
26 endfunc | 26 endfunc |
27 | 27 |
28 func Test_setpos() | 28 func Test_setpos() |
29 new one | 29 new Xone |
30 let onebuf = bufnr('%') | 30 let onebuf = bufnr('%') |
31 let onewin = win_getid() | 31 let onewin = win_getid() |
32 call setline(1, ['aaa', 'bbb', 'ccc']) | 32 call setline(1, ['aaa', 'bbb', 'ccc']) |
33 new two | 33 new Xtwo |
34 let twobuf = bufnr('%') | 34 let twobuf = bufnr('%') |
35 let twowin = win_getid() | 35 let twowin = win_getid() |
36 call setline(1, ['aaa', 'bbb', 'ccc']) | 36 call setline(1, ['aaa', 'bbb', 'ccc']) |
37 | 37 |
38 " for the cursor the buffer number is ignored | 38 " for the cursor the buffer number is ignored |
61 call setpos("'N", [0, 2, 1, 0]) | 61 call setpos("'N", [0, 2, 1, 0]) |
62 call assert_equal([twobuf, 2, 1, 0], getpos("'N")) | 62 call assert_equal([twobuf, 2, 1, 0], getpos("'N")) |
63 call setpos("'N", [onebuf, 1, 3, 0]) | 63 call setpos("'N", [onebuf, 1, 3, 0]) |
64 call assert_equal([onebuf, 1, 3, 0], getpos("'N")) | 64 call assert_equal([onebuf, 1, 3, 0], getpos("'N")) |
65 | 65 |
66 " try invalid column and check virtcol() | |
66 call win_gotoid(onewin) | 67 call win_gotoid(onewin) |
68 call setpos("'a", [0, 1, 2, 0]) | |
69 call assert_equal([0, 1, 2, 0], getpos("'a")) | |
70 call setpos("'a", [0, 1, -5, 0]) | |
71 call assert_equal([0, 1, 2, 0], getpos("'a")) | |
72 call setpos("'a", [0, 1, 0, 0]) | |
73 call assert_equal([0, 1, 1, 0], getpos("'a")) | |
74 call setpos("'a", [0, 1, 4, 0]) | |
75 call assert_equal([0, 1, 4, 0], getpos("'a")) | |
76 call assert_equal(4, virtcol("'a")) | |
77 call setpos("'a", [0, 1, 5, 0]) | |
78 call assert_equal([0, 1, 5, 0], getpos("'a")) | |
79 call assert_equal(4, virtcol("'a")) | |
80 call setpos("'a", [0, 1, 21341234, 0]) | |
81 call assert_equal([0, 1, 21341234, 0], getpos("'a")) | |
82 call assert_equal(4, virtcol("'a")) | |
83 | |
67 bwipe! | 84 bwipe! |
68 call win_gotoid(twowin) | 85 call win_gotoid(twowin) |
69 bwipe! | 86 bwipe! |
70 endfunc | 87 endfunc |
71 | 88 |