mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 01:08:20 +00:00
vim-patch:8.0.0374: invalid memory access when using :sc in Ex mode (#7849)
Problem: Invalid memory access when using :sc in Ex mode. (Dominique Pelle)
Solution: Avoid the column being negative. Also fix a hang in Ex mode.
ba748c8a84
This commit is contained in:

committed by
Justin M. Keyes

parent
f8f7f9d5f5
commit
26251d6d06
@@ -3541,6 +3541,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout)
|
|||||||
|
|
||||||
getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);
|
getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);
|
||||||
curwin->w_cursor.col = regmatch.endpos[0].col - 1;
|
curwin->w_cursor.col = regmatch.endpos[0].col - 1;
|
||||||
|
if (curwin->w_cursor.col < 0) {
|
||||||
|
curwin->w_cursor.col = 0;
|
||||||
|
}
|
||||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);
|
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);
|
||||||
if (subflags.do_number || curwin->w_p_nu) {
|
if (subflags.do_number || curwin->w_p_nu) {
|
||||||
int numw = number_width(curwin) + 1;
|
int numw = number_width(curwin) + 1;
|
||||||
|
@@ -2164,7 +2164,13 @@ getexmodeline (
|
|||||||
/* Get one character at a time. Don't use inchar(), it can't handle
|
/* Get one character at a time. Don't use inchar(), it can't handle
|
||||||
* special characters. */
|
* special characters. */
|
||||||
prev_char = c1;
|
prev_char = c1;
|
||||||
|
|
||||||
|
// Check for a ":normal" command and no more characters left.
|
||||||
|
if (ex_normal_busy > 0 && typebuf.tb_len == 0) {
|
||||||
|
c1 = '\n';
|
||||||
|
} else {
|
||||||
c1 = vgetc();
|
c1 = vgetc();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle line editing.
|
* Handle line editing.
|
||||||
|
@@ -106,3 +106,11 @@ function! Test_substitute_variants()
|
|||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
func Test_substitute_repeat()
|
||||||
|
" This caused an invalid memory access.
|
||||||
|
split Xfile
|
||||||
|
s/^/x
|
||||||
|
call feedkeys("Qsc\<CR>y", 'tx')
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
Reference in New Issue
Block a user