Skip to content

Commit f7c7c3f

Browse files
committed
patch 8.2.5150: read past the end of the first line with ":0;'{"
Problem: Read past the end of the first line with ":0;'{". Solution: When on line zero check the column is valid for line one.
1 parent 6689df0 commit f7c7c3f

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/ex_docmd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3411,10 +3411,13 @@ parse_cmd_address(exarg_T *eap, char **errormsg, int silent)
34113411
curwin->w_cursor.lnum = eap->line2;
34123412

34133413
// Don't leave the cursor on an illegal line or column, but do
3414-
// accept zero as address, so 0;/PATTERN/ works correctly.
3414+
// accept zero as address, so 0;/PATTERN/ works correctly
3415+
// (where zero usually means to use the first line).
34153416
// Check the cursor position before returning.
34163417
if (eap->line2 > 0)
34173418
check_cursor();
3419+
else
3420+
check_cursor_col();
34183421
need_check_cursor = TRUE;
34193422
}
34203423
}

src/testdir/test_cmdline.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,14 @@ func Test_illegal_address2()
808808
call delete('Xtest.vim')
809809
endfunc
810810

811+
func Test_mark_from_line_zero()
812+
" this was reading past the end of the first (empty) line
813+
new
814+
norm oxxxx
815+
call assert_fails("0;'(", 'E20:')
816+
bwipe!
817+
endfunc
818+
811819
func Test_cmdline_complete_wildoptions()
812820
help
813821
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
5150,
737739
/**/
738740
5149,
739741
/**/

0 commit comments

Comments
 (0)