0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.3916: no error for passing an invalid line number to append()

Problem:    No error for passing an invalid line number to append().
Solution:   In Vim9 script check for a non-negative number. (closes #9417)
This commit is contained in:
Bram Moolenaar
2021-12-27 20:57:06 +00:00
parent 4b28ba3245
commit 8dac2acd6a
7 changed files with 31 additions and 8 deletions

View File

@@ -5359,8 +5359,9 @@ var2fpos(
name = tv_get_string_chk(varp);
if (name == NULL)
return NULL;
if (name[0] == '.') // cursor
if (name[0] == '.' && (!in_vim9script() || name[1] == NUL))
{
// cursor
pos = curwin->w_cursor;
if (charcol)
pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col);
@@ -5376,8 +5377,10 @@ var2fpos(
pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col);
return &pos;
}
if (name[0] == '\'') // mark
if (name[0] == '\'' && (!in_vim9script()
|| (name[1] != NUL && name[2] == NUL)))
{
// mark
pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);
if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)
return NULL;