]> granicus.if.org Git - vim/commitdiff
patch 8.2.5148: invalid memory access when using expression on command line v8.2.5148
authorBram Moolenaar <Bram@vim.org>
Wed, 22 Jun 2022 12:51:54 +0000 (13:51 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 22 Jun 2022 12:51:54 +0000 (13:51 +0100)
Problem:    Invalid memory access when using an expression on the command line.
Solution:   Make sure the position does not go negative.

src/ex_getln.c
src/testdir/test_cmdline.vim
src/version.c

index af4dc19be198a1aa294362e477aaebad013e24da..b499aba141b670cbef340f72cc0aa581e14f2355 100644 (file)
@@ -1206,6 +1206,7 @@ cmdline_insert_reg(int *gotesc UNUSED)
 {
     int                i;
     int                c;
+    int                save_new_cmdpos = new_cmdpos;
 
 #ifdef USE_ON_FLY_SCROLL
     dont_scroll = TRUE;        // disallow scrolling here
@@ -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 == '=')
@@ -1266,6 +1265,8 @@ cmdline_insert_reg(int *gotesc UNUSED)
        }
 #endif
     }
+    new_cmdpos = save_new_cmdpos;
+
     // remove the double quote
     redrawcmd();
 
index 2289c343e9f8259191074857f49b1b20e44079f0..9c08d138042abc92ceaeea3dff0101d0f309b300 100644 (file)
@@ -1987,6 +1987,11 @@ func Test_cmdline_expr()
   call assert_equal("\"e \<C-\>\<C-Y>", @:)
 endfunc
 
+" This was making the insert position negative
+func Test_cmdline_expr_register()
+  exe "sil! norm! ?\<C-\>e0\<C-R>0\<Esc>?\<C-\>e0\<CR>"
+endfunc
+
 " Test for 'imcmdline' and 'imsearch'
 " This test doesn't actually test the input method functionality.
 func Test_cmdline_inputmethod()
index 35024fb59405f95126904d21ad238c866718cb11..e567a3a9995ab3a1075b7bcad4b17ebfef155344 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5148,
 /**/
     5147,
 /**/