mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.0.2159: screenpos() may crash with neg. column
Problem: screenpos() may crash with neg. column Solution: validate and correct column closes: vim/vim#13669ec54af4e26
(cherry picked from commit6052fac625
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
59dd7aed40
commit
9caec77fae
@@ -1025,6 +1025,9 @@ void f_screenpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
semsg(_(e_invalid_line_number_nr), pos.lnum);
|
semsg(_(e_invalid_line_number_nr), pos.lnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (pos.col < 0) {
|
||||||
|
pos.col = 0;
|
||||||
|
}
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int scol = 0, ccol = 0, ecol = 0;
|
int scol = 0, ccol = 0, ecol = 0;
|
||||||
textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol, false);
|
textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol, false);
|
||||||
|
@@ -173,6 +173,11 @@ func Test_screenpos()
|
|||||||
call assert_equal(#{col: 1, row: 2, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
|
call assert_equal(#{col: 1, row: 2, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
|
||||||
" nunmenu WinBar.TEST
|
" nunmenu WinBar.TEST
|
||||||
setlocal winbar&
|
setlocal winbar&
|
||||||
|
call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
|
||||||
|
|
||||||
|
call assert_equal(#{col: 0, row: 0, endcol: 0, curscol: 0}, screenpos(0, 0, 1))
|
||||||
|
call assert_equal(#{col: 0, row: 0, endcol: 0, curscol: 0}, screenpos(0, -1, 1))
|
||||||
|
call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(0, 1, -v:maxcol))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_screenpos_fold()
|
func Test_screenpos_fold()
|
||||||
|
Reference in New Issue
Block a user