Skip to content

Commit

Permalink
patch 9.0.0025: accessing beyond allocated memory with the cmdline wi…
Browse files Browse the repository at this point in the history
…ndow

Problem:    Accessing beyond allocated memory when using the cmdline window in
            Ex mode.
Solution:   Use "*" instead of "'<,'>" for Visual mode.
  • Loading branch information
brammool committed Jul 2, 2022
1 parent af043e1 commit c6fdb15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ex_docmd.c
Expand Up @@ -3118,9 +3118,11 @@ parse_command_modifiers(
size_t len = STRLEN(cmd_start);

// Special case: empty command uses "+":
// "'<,'>mods" -> "mods'<,'>+
// "'<,'>mods" -> "mods *+
// Use "*" instead of "'<,'>" to avoid the command getting
// longer, in case is was allocated.
mch_memmove(orig_cmd, cmd_start, len);
STRCPY(orig_cmd + len, "'<,'>+");
STRCPY(orig_cmd + len, " *+");
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions src/testdir/test_cmdline.vim
Expand Up @@ -2103,6 +2103,14 @@ func Test_cmdwin_insert_mode_close()
call assert_equal(1, winnr('$'))
endfunc

func Test_cmdwin_ex_mode_with_modifier()
" this was accessing memory after allocated text in Ex mode
new
call setline(1, ['some', 'text', 'lines'])
silent! call feedkeys("gQnormal vq:atopleft\<C-V>\<CR>\<CR>", 'xt')
bwipe!
endfunc

" test that ";" works to find a match at the start of the first line
func Test_zero_line_search()
new
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
25,
/**/
24,
/**/
Expand Down

0 comments on commit c6fdb15

Please sign in to comment.