Skip to content

Commit 6046ade

Browse files
committed
patch 8.2.5148: invalid memory access when using expression on command line
Problem: Invalid memory access when using an expression on the command line. Solution: Make sure the position does not go negative.
1 parent 12a4940 commit 6046ade

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/ex_getln.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ cmdline_insert_reg(int *gotesc UNUSED)
12061206
{
12071207
int i;
12081208
int c;
1209+
int save_new_cmdpos = new_cmdpos;
12091210

12101211
#ifdef USE_ON_FLY_SCROLL
12111212
dont_scroll = TRUE; // disallow scrolling here
@@ -1224,8 +1225,6 @@ cmdline_insert_reg(int *gotesc UNUSED)
12241225
#ifdef FEAT_EVAL
12251226
/*
12261227
* Insert the result of an expression.
1227-
* Need to save the current command line, to be able to enter
1228-
* a new one...
12291228
*/
12301229
new_cmdpos = -1;
12311230
if (c == '=')
@@ -1266,6 +1265,8 @@ cmdline_insert_reg(int *gotesc UNUSED)
12661265
}
12671266
#endif
12681267
}
1268+
new_cmdpos = save_new_cmdpos;
1269+
12691270
// remove the double quote
12701271
redrawcmd();
12711272

src/testdir/test_cmdline.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,11 @@ func Test_cmdline_expr()
19871987
call assert_equal("\"e \<C-\>\<C-Y>", @:)
19881988
endfunc
19891989

1990+
" This was making the insert position negative
1991+
func Test_cmdline_expr_register()
1992+
exe "sil! norm! ?\<C-\>e0\<C-R>0\<Esc>?\<C-\>e0\<CR>"
1993+
endfunc
1994+
19901995
" Test for 'imcmdline' and 'imsearch'
19911996
" This test doesn't actually test the input method functionality.
19921997
func Test_cmdline_inputmethod()

src/version.c

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

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
5148,
737739
/**/
738740
5147,
739741
/**/

0 commit comments

Comments
 (0)