diff src/getchar.c @ 32122:a2dd770c854a v9.0.1392

patch 9.0.1392: using NULL pointer with nested :open command Commit: https://github.com/vim/vim/commit/7ac5023a5f1a37baafbe1043645f97ba3443d9f6 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 7 21:05:04 2023 +0000 patch 9.0.1392: using NULL pointer with nested :open command Problem: Using NULL pointer with nested :open command. Solution: Check that ccline.cmdbuff is not NULL.
author Bram Moolenaar <Bram@vim.org>
date Tue, 07 Mar 2023 22:15:04 +0100
parents 879456b2022b
children cf48f4b9dc0a
line wrap: on
line diff
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -3107,7 +3107,7 @@ check_end_reg_executing(int advance)
     static int
 vgetorpeek(int advance)
 {
-    int		c, c1;
+    int		c;
     int		timedout = FALSE;	// waited for more than 'timeoutlen'
 					// for mapping to complete or
 					// 'ttimeoutlen' for complete key code
@@ -3474,7 +3474,7 @@ vgetorpeek(int advance)
 		 * to the user with showcmd.
 		 */
 		showcmd_idx = 0;
-		c1 = 0;
+		int showing_partial = FALSE;
 		if (typebuf.tb_len > 0 && advance && !exmode_active)
 		{
 		    if (((State & (MODE_NORMAL | MODE_INSERT))
@@ -3489,7 +3489,7 @@ vgetorpeek(int advance)
 			    edit_putchar(typebuf.tb_buf[typebuf.tb_off
 						+ typebuf.tb_len - 1], FALSE);
 			    setcursor(); // put cursor back where it belongs
-			    c1 = 1;
+			    showing_partial = TRUE;
 			}
 			// need to use the col and row from above here
 			old_wcol = curwin->w_wcol;
@@ -3506,8 +3506,10 @@ vgetorpeek(int advance)
 			curwin->w_wrow = old_wrow;
 		    }
 
-		    // this looks nice when typing a dead character map
+		    // This looks nice when typing a dead character map.
+		    // There is no actual command line for get_number().
 		    if ((State & MODE_CMDLINE)
+			    && get_cmdline_info()->cmdbuff != NULL
 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
 			    && cmdline_star == 0
 #endif
@@ -3516,7 +3518,7 @@ vgetorpeek(int advance)
 		    {
 			putcmdline(typebuf.tb_buf[typebuf.tb_off
 						+ typebuf.tb_len - 1], FALSE);
-			c1 = 1;
+			showing_partial = TRUE;
 		    }
 		}
 
@@ -3550,11 +3552,12 @@ vgetorpeek(int advance)
 
 		if (showcmd_idx != 0)
 		    pop_showcmd();
-		if (c1 == 1)
+		if (showing_partial)
 		{
 		    if (State & MODE_INSERT)
 			edit_unputchar();
-		    if (State & MODE_CMDLINE)
+		    if ((State & MODE_CMDLINE)
+					&& get_cmdline_info()->cmdbuff != NULL)
 			unputcmdline();
 		    else
 			setcursor();	// put cursor back where it belongs