comparison 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
comparison
equal deleted inserted replaced
32121:b8cdbccec740 32122:a2dd770c854a
3105 * K_SPECIAL and CSI may be escaped, need to get two more bytes then. 3105 * K_SPECIAL and CSI may be escaped, need to get two more bytes then.
3106 */ 3106 */
3107 static int 3107 static int
3108 vgetorpeek(int advance) 3108 vgetorpeek(int advance)
3109 { 3109 {
3110 int c, c1; 3110 int c;
3111 int timedout = FALSE; // waited for more than 'timeoutlen' 3111 int timedout = FALSE; // waited for more than 'timeoutlen'
3112 // for mapping to complete or 3112 // for mapping to complete or
3113 // 'ttimeoutlen' for complete key code 3113 // 'ttimeoutlen' for complete key code
3114 int mapdepth = 0; // check for recursive mapping 3114 int mapdepth = 0; // check for recursive mapping
3115 int mode_deleted = FALSE; // set when mode has been deleted 3115 int mode_deleted = FALSE; // set when mode has been deleted
3472 * If we have a partial match (and are going to wait for more 3472 * If we have a partial match (and are going to wait for more
3473 * input from the user), show the partially matched characters 3473 * input from the user), show the partially matched characters
3474 * to the user with showcmd. 3474 * to the user with showcmd.
3475 */ 3475 */
3476 showcmd_idx = 0; 3476 showcmd_idx = 0;
3477 c1 = 0; 3477 int showing_partial = FALSE;
3478 if (typebuf.tb_len > 0 && advance && !exmode_active) 3478 if (typebuf.tb_len > 0 && advance && !exmode_active)
3479 { 3479 {
3480 if (((State & (MODE_NORMAL | MODE_INSERT)) 3480 if (((State & (MODE_NORMAL | MODE_INSERT))
3481 || State == MODE_LANGMAP) 3481 || State == MODE_LANGMAP)
3482 && State != MODE_HITRETURN) 3482 && State != MODE_HITRETURN)
3487 + typebuf.tb_len - 1) == 1) 3487 + typebuf.tb_len - 1) == 1)
3488 { 3488 {
3489 edit_putchar(typebuf.tb_buf[typebuf.tb_off 3489 edit_putchar(typebuf.tb_buf[typebuf.tb_off
3490 + typebuf.tb_len - 1], FALSE); 3490 + typebuf.tb_len - 1], FALSE);
3491 setcursor(); // put cursor back where it belongs 3491 setcursor(); // put cursor back where it belongs
3492 c1 = 1; 3492 showing_partial = TRUE;
3493 } 3493 }
3494 // need to use the col and row from above here 3494 // need to use the col and row from above here
3495 old_wcol = curwin->w_wcol; 3495 old_wcol = curwin->w_wcol;
3496 old_wrow = curwin->w_wrow; 3496 old_wrow = curwin->w_wrow;
3497 curwin->w_wcol = new_wcol; 3497 curwin->w_wcol = new_wcol;
3504 typebuf.tb_buf[typebuf.tb_off + showcmd_idx++]); 3504 typebuf.tb_buf[typebuf.tb_off + showcmd_idx++]);
3505 curwin->w_wcol = old_wcol; 3505 curwin->w_wcol = old_wcol;
3506 curwin->w_wrow = old_wrow; 3506 curwin->w_wrow = old_wrow;
3507 } 3507 }
3508 3508
3509 // this looks nice when typing a dead character map 3509 // This looks nice when typing a dead character map.
3510 // There is no actual command line for get_number().
3510 if ((State & MODE_CMDLINE) 3511 if ((State & MODE_CMDLINE)
3512 && get_cmdline_info()->cmdbuff != NULL
3511 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) 3513 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
3512 && cmdline_star == 0 3514 && cmdline_star == 0
3513 #endif 3515 #endif
3514 && ptr2cells(typebuf.tb_buf + typebuf.tb_off 3516 && ptr2cells(typebuf.tb_buf + typebuf.tb_off
3515 + typebuf.tb_len - 1) == 1) 3517 + typebuf.tb_len - 1) == 1)
3516 { 3518 {
3517 putcmdline(typebuf.tb_buf[typebuf.tb_off 3519 putcmdline(typebuf.tb_buf[typebuf.tb_off
3518 + typebuf.tb_len - 1], FALSE); 3520 + typebuf.tb_len - 1], FALSE);
3519 c1 = 1; 3521 showing_partial = TRUE;
3520 } 3522 }
3521 } 3523 }
3522 3524
3523 /* 3525 /*
3524 * get a character: 3. from the user - get it 3526 * get a character: 3. from the user - get it
3548 typebuf.tb_buflen - typebuf.tb_off - typebuf.tb_len - 1, 3550 typebuf.tb_buflen - typebuf.tb_off - typebuf.tb_len - 1,
3549 wait_time); 3551 wait_time);
3550 3552
3551 if (showcmd_idx != 0) 3553 if (showcmd_idx != 0)
3552 pop_showcmd(); 3554 pop_showcmd();
3553 if (c1 == 1) 3555 if (showing_partial)
3554 { 3556 {
3555 if (State & MODE_INSERT) 3557 if (State & MODE_INSERT)
3556 edit_unputchar(); 3558 edit_unputchar();
3557 if (State & MODE_CMDLINE) 3559 if ((State & MODE_CMDLINE)
3560 && get_cmdline_info()->cmdbuff != NULL)
3558 unputcmdline(); 3561 unputcmdline();
3559 else 3562 else
3560 setcursor(); // put cursor back where it belongs 3563 setcursor(); // put cursor back where it belongs
3561 } 3564 }
3562 3565