vim-patch:9.1.1463: Integer overflow in getmarklist() after linewise operation (#34532)

Problem:  Integer overflow in getmarklist() after linewise operation.
Solution: Don't add 1 to MAXCOL (zeertzjq)

related: neovim/neovim#34524
closes: vim/vim#17552

93318a9933
(cherry picked from commit 3e984cf02b)
This commit is contained in:
zeertzjq
2025-06-17 07:24:52 +08:00
committed by github-actions[bot]
parent 1077374380
commit 9ffa94b07b
2 changed files with 6 additions and 1 deletions

View File

@ -1796,7 +1796,7 @@ static int add_mark(list_T *l, const char *mname, const pos_T *pos, int bufnr, c
tv_list_append_number(lpos, bufnr);
tv_list_append_number(lpos, pos->lnum);
tv_list_append_number(lpos, pos->col + 1);
tv_list_append_number(lpos, pos->col < MAXCOL ? pos->col + 1 : MAXCOL);
tv_list_append_number(lpos, pos->coladd);
if (tv_dict_add_str(d, S_LEN("mark"), mname) == FAIL

View File

@ -301,6 +301,11 @@ func Test_getmarklist()
call assert_equal({'mark' : "'r", 'pos' : [bufnr(), 2, 2, 0]},
\ bufnr()->getmarklist()[0])
call assert_equal([], {}->getmarklist())
normal! yy
call assert_equal([
\ {'mark': "'[", 'pos': [bufnr(), 2, 1, 0]},
\ {'mark': "']", 'pos': [bufnr(), 2, v:maxcol, 0]},
\ ], getmarklist(bufnr())[-2:])
close!
endfunc