mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 14:55:33 +00:00
vim-patch:9.0.0025: accessing beyond allocated memory with the cmdline window
Problem: Accessing beyond allocated memory when using the cmdline window in
Ex mode.
Solution: Use "*" instead of "'<,'>" for Visual mode.
c6fdb15d42
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2777,9 +2777,11 @@ int parse_command_modifiers(exarg_T *eap, const char **errormsg, cmdmod_T *cmod,
|
|||||||
size_t len = strlen(cmd_start);
|
size_t len = strlen(cmd_start);
|
||||||
|
|
||||||
// Special case: empty command uses "+":
|
// Special case: empty command uses "+":
|
||||||
// "'<,'>mods" -> "mods'<,'>+
|
// "'<,'>mods" -> "mods *+
|
||||||
|
// Use "*" instead of "'<,'>" to avoid the command getting
|
||||||
|
// longer, in case is was allocated.
|
||||||
memmove(orig_cmd, cmd_start, len);
|
memmove(orig_cmd, cmd_start, len);
|
||||||
strcpy(orig_cmd + len, "'<,'>+");
|
xmemcpyz(orig_cmd + len, S_LEN(" *+"));
|
||||||
} else {
|
} else {
|
||||||
memmove(cmd_start - 5, cmd_start, (size_t)(eap->cmd - cmd_start));
|
memmove(cmd_start - 5, cmd_start, (size_t)(eap->cmd - cmd_start));
|
||||||
eap->cmd -= 5;
|
eap->cmd -= 5;
|
||||||
|
|||||||
@@ -2561,6 +2561,14 @@ func Test_cmdwin_insert_mode_close()
|
|||||||
call assert_equal(1, winnr('$'))
|
call assert_equal(1, winnr('$'))
|
||||||
endfunc
|
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
|
" test that ";" works to find a match at the start of the first line
|
||||||
func Test_zero_line_search()
|
func Test_zero_line_search()
|
||||||
new
|
new
|
||||||
|
|||||||
Reference in New Issue
Block a user