aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKunMing Xie <qqzz014@gmail.com>2018-01-16 06:54:56 +0800
committerJustin M. Keyes <justinkz@gmail.com>2018-01-15 23:54:56 +0100
commit26251d6d0681194e7dc57fa2dfb8857576faed21 (patch)
treec7feb84629482a677926d071801511d4d0f35119
parentf8f7f9d5f5aead86541ffcd12e291b6dfb6811e5 (diff)
downloadrneovim-26251d6d0681194e7dc57fa2dfb8857576faed21.tar.gz
rneovim-26251d6d0681194e7dc57fa2dfb8857576faed21.tar.bz2
rneovim-26251d6d0681194e7dc57fa2dfb8857576faed21.zip
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. https://github.com/vim/vim/commit/ba748c8a847561c043a63827bcb1d98bdebe16e6
-rw-r--r--src/nvim/ex_cmds.c3
-rw-r--r--src/nvim/ex_getln.c8
-rw-r--r--src/nvim/testdir/test_substitute.vim8
3 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index c5825963c0..06379f159c 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3541,6 +3541,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout)
getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);
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);
if (subflags.do_number || curwin->w_p_nu) {
int numw = number_width(curwin) + 1;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index a5a8804e1c..82fac8d78e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2164,7 +2164,13 @@ getexmodeline (
/* Get one character at a time. Don't use inchar(), it can't handle
* special characters. */
prev_char = c1;
- c1 = vgetc();
+
+ // Check for a ":normal" command and no more characters left.
+ if (ex_normal_busy > 0 && typebuf.tb_len == 0) {
+ c1 = '\n';
+ } else {
+ c1 = vgetc();
+ }
/*
* Handle line editing.
diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim
index a3bc04dcd0..f2dfdc7019 100644
--- a/src/nvim/testdir/test_substitute.vim
+++ b/src/nvim/testdir/test_substitute.vim
@@ -106,3 +106,11 @@ function! Test_substitute_variants()
endfor
endfor
endfunction
+
+func Test_substitute_repeat()
+ " This caused an invalid memory access.
+ split Xfile
+ s/^/x
+ call feedkeys("Qsc\<CR>y", 'tx')
+ bwipe!
+endfunc