diff src/ex_getln.c @ 29259:a5846b82119b v8.2.5148

patch 8.2.5148: invalid memory access when using expression on command line Commit: https://github.com/vim/vim/commit/6046aded8da002b08d380db29de2ba0268b6616e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 22 13:51:54 2022 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Wed, 22 Jun 2022 15:00:05 +0200
parents 1ec1ba7e7728
children 2f2c3448a337
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -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();