Skip to content

Commit 2efb323

Browse files
committed
patch 8.0.1411: reading invalid memory with CTRL-W :
Problem: Reading invalid memory with CTRL-W :. Solution: Correct the command characters. (closes #2469)
1 parent 338e47f commit 2efb323

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/normal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7850,8 +7850,12 @@ n_start_visual_mode(int c)
78507850
nv_window(cmdarg_T *cap)
78517851
{
78527852
if (cap->nchar == ':')
7853+
{
78537854
/* "CTRL-W :" is the same as typing ":"; useful in a terminal window */
7855+
cap->cmdchar = ':';
7856+
cap->nchar = NUL;
78547857
nv_colon(cap);
7858+
}
78557859
else if (!checkclearop(cap->oap))
78567860
do_window(cap->nchar, cap->count0, NUL); /* everything is in window.c */
78577861
}

src/ops.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,15 @@ get_op_type(int char1, int char2)
183183
if (char1 == 'g' && char2 == Ctrl_X) /* subtract */
184184
return OP_NR_SUB;
185185
for (i = 0; ; ++i)
186+
{
186187
if (opchars[i][0] == char1 && opchars[i][1] == char2)
187188
break;
189+
if (i == (int)(sizeof(opchars) / sizeof(char [3]) - 1))
190+
{
191+
internal_error("get_op_type()");
192+
break;
193+
}
194+
}
188195
return i;
189196
}
190197

src/testdir/test_window_cmd.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,9 @@ func Test_window_contents()
467467
call test_garbagecollect_now()
468468
endfunc
469469

470+
func Test_window_colon_command()
471+
" This was reading invalid memory.
472+
exe "norm! v\<C-W>:\<C-U>echo v:version"
473+
endfunc
474+
470475
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1411,
774776
/**/
775777
1410,
776778
/**/

0 commit comments

Comments
 (0)