Skip to content


patch 8.2.5148: invalid memory access when using expression on comman…
Browse files Browse the repository at this point in the history
…d line

Problem:    Invalid memory access when using an expression on the command line.
Solution:   Make sure the position does not go negative.
  • Loading branch information
brammool committed Jun 22, 2022
1 parent 12a4940 commit 6046ade
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ex_getln.c
Expand Up @@ -1206,6 +1206,7 @@ cmdline_insert_reg(int *gotesc UNUSED)
int i;
int c;
int save_new_cmdpos = new_cmdpos;

This comment has been minimized.

Copy link

djklimes Jun 22, 2022

When I build this change with:
./configure --with-features=tiny --enable-perlinterp=no --enable-pythoninterp=no --enable-python3interp=no --enable-rubyinterp=no --enable-luainterp=no --with-vim-name=vim-minimal --enable-gui=no
it fails with:
ex_getln.c:1209:35: error: ‘new_cmdpos’ undeclared (first use in this function); did you mean ‘set_cmdspos’?
1209 | int save_new_cmdpos = new_cmdpos;

dont_scroll = TRUE; // disallow scrolling here
Expand All @@ -1224,8 +1225,6 @@ cmdline_insert_reg(int *gotesc UNUSED)
#ifdef FEAT_EVAL
* Insert the result of an expression.
* Need to save the current command line, to be able to enter
* a new one...
new_cmdpos = -1;
if (c == '=')
Expand Down Expand Up @@ -1266,6 +1265,8 @@ cmdline_insert_reg(int *gotesc UNUSED)
new_cmdpos = save_new_cmdpos;

// remove the double quote

Expand Down
5 changes: 5 additions & 0 deletions src/testdir/test_cmdline.vim
Expand Up @@ -1987,6 +1987,11 @@ func Test_cmdline_expr()
call assert_equal("\"e \<C-\>\<C-Y>", @:)

" This was making the insert position negative
func Test_cmdline_expr_register()
exe "sil! norm! ?\<C-\>e0\<C-R>0\<Esc>?\<C-\>e0\<CR>"

" Test for 'imcmdline' and 'imsearch'
" This test doesn't actually test the input method functionality.
func Test_cmdline_inputmethod()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
Expand Down

1 comment on commit 6046ade

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the same problem, but only on Tiny (like here) and Small builds, as mentioned a few minutes ago on the vim-dev group. Normal, Big and Huge build normally for me.

Best regards,

Please sign in to comment.