From d8d4f05564c32510f4ea7eb4f8ae5e3769f2f57d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 10 Apr 2019 20:34:48 -0400 Subject: vim-patch:8.0.1411: reading invalid memory with CTRL-W : Problem: Reading invalid memory with CTRL-W :. Solution: Correct the command characters. (closes vim/vim#2469) https://github.com/vim/vim/commit/2efb323e875d2852f63e41c40641760d1d6b069f --- src/nvim/normal.c | 2 ++ src/nvim/ops.c | 4 ++++ src/nvim/testdir/test_window_cmd.vim | 5 +++++ 3 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ad811a101a..5217db5b42 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6528,6 +6528,8 @@ static void nv_window(cmdarg_T *cap) { if (cap->nchar == ':') { // "CTRL-W :" is the same as typing ":"; useful in a terminal window + cap->cmdchar = ':'; + cap->nchar = NUL; nv_colon(cap); } else if (!checkclearop(cap->oap)) { do_window(cap->nchar, cap->count0, NUL); // everything is in window.c diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 0ed96f0e57..caa7ab9639 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -153,6 +153,10 @@ int get_op_type(int char1, int char2) if (opchars[i][0] == char1 && opchars[i][1] == char2) { break; } + if (i == (int)(sizeof(opchars) / sizeof(char [3]) - 1)) { + internal_error("get_op_type()"); + break; + } } return i; } diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index d3b496635d..003a23ea7b 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -691,4 +691,9 @@ func Test_winnr() only | tabonly endfunc +func Test_window_colon_command() + " This was reading invalid memory. + exe "norm! v\:\echo v:version" +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit