mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1392: using NULL pointer with nested :open command (#22583)
Problem: Using NULL pointer with nested :open command.
Solution: Check that ccline.cmdbuff is not NULL.
7ac5023a5f
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
be0461e3c2
commit
eaccd0decd
@ -2345,7 +2345,7 @@ void check_end_reg_executing(bool advance)
|
|||||||
/// K_SPECIAL may be escaped, need to get two more bytes then.
|
/// K_SPECIAL may be escaped, need to get two more bytes then.
|
||||||
static int vgetorpeek(bool advance)
|
static int vgetorpeek(bool advance)
|
||||||
{
|
{
|
||||||
int c, c1;
|
int c;
|
||||||
bool timedout = false; // waited for more than 'timeoutlen'
|
bool timedout = false; // waited for more than 'timeoutlen'
|
||||||
// for mapping to complete or
|
// for mapping to complete or
|
||||||
// 'ttimeoutlen' for complete key code
|
// 'ttimeoutlen' for complete key code
|
||||||
@ -2639,7 +2639,7 @@ static int vgetorpeek(bool advance)
|
|||||||
// input from the user), show the partially matched characters
|
// input from the user), show the partially matched characters
|
||||||
// to the user with showcmd.
|
// to the user with showcmd.
|
||||||
int showcmd_idx = 0;
|
int showcmd_idx = 0;
|
||||||
c1 = 0;
|
bool showing_partial = false;
|
||||||
if (typebuf.tb_len > 0 && advance && !exmode_active) {
|
if (typebuf.tb_len > 0 && advance && !exmode_active) {
|
||||||
if (((State & (MODE_NORMAL | MODE_INSERT)) || State == MODE_LANGMAP)
|
if (((State & (MODE_NORMAL | MODE_INSERT)) || State == MODE_LANGMAP)
|
||||||
&& State != MODE_HITRETURN) {
|
&& State != MODE_HITRETURN) {
|
||||||
@ -2648,7 +2648,7 @@ static int vgetorpeek(bool advance)
|
|||||||
&& ptr2cells((char *)typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1) == 1) {
|
&& ptr2cells((char *)typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1) == 1) {
|
||||||
edit_putchar(typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len - 1], false);
|
edit_putchar(typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len - 1], false);
|
||||||
setcursor(); // put cursor back where it belongs
|
setcursor(); // put cursor back where it belongs
|
||||||
c1 = 1;
|
showing_partial = true;
|
||||||
}
|
}
|
||||||
// need to use the col and row from above here
|
// need to use the col and row from above here
|
||||||
old_wcol = curwin->w_wcol;
|
old_wcol = curwin->w_wcol;
|
||||||
@ -2666,12 +2666,15 @@ static int vgetorpeek(bool advance)
|
|||||||
curwin->w_wrow = old_wrow;
|
curwin->w_wrow = old_wrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this looks nice when typing a dead character map
|
// This looks nice when typing a dead character map.
|
||||||
if ((State & MODE_CMDLINE) && cmdline_star == 0) {
|
// There is no actual command line for get_number().
|
||||||
|
if ((State & MODE_CMDLINE)
|
||||||
|
&& get_cmdline_info()->cmdbuff != NULL
|
||||||
|
&& cmdline_star == 0) {
|
||||||
char *p = (char *)typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1;
|
char *p = (char *)typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1;
|
||||||
if (ptr2cells(p) == 1 && (uint8_t)(*p) < 128) {
|
if (ptr2cells(p) == 1 && (uint8_t)(*p) < 128) {
|
||||||
putcmdline(*p, false);
|
putcmdline(*p, false);
|
||||||
c1 = 1;
|
showing_partial = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2704,11 +2707,12 @@ static int vgetorpeek(bool advance)
|
|||||||
if (showcmd_idx != 0) {
|
if (showcmd_idx != 0) {
|
||||||
pop_showcmd();
|
pop_showcmd();
|
||||||
}
|
}
|
||||||
if (c1 == 1) {
|
if (showing_partial == 1) {
|
||||||
if (State & MODE_INSERT) {
|
if (State & MODE_INSERT) {
|
||||||
edit_unputchar();
|
edit_unputchar();
|
||||||
}
|
}
|
||||||
if (State & MODE_CMDLINE) {
|
if ((State & MODE_CMDLINE)
|
||||||
|
&& get_cmdline_info()->cmdbuff != NULL) {
|
||||||
unputcmdline();
|
unputcmdline();
|
||||||
} else {
|
} else {
|
||||||
setcursor(); // put cursor back where it belongs
|
setcursor(); // put cursor back where it belongs
|
||||||
|
@ -137,6 +137,28 @@ func Test_open_command_flush_line()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" FIXME: this doesn't fail without the fix but hangs
|
||||||
|
func Skip_Test_open_command_state()
|
||||||
|
" Tricky script that failed because State was not set properly
|
||||||
|
let lines =<< trim END
|
||||||
|
!ls
|
||||||
|
0scìi
|
||||||
|
so! Xsourced
|
||||||
|
set t_û0=0
|
||||||
|
v/-/o
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XopenScript', '')
|
||||||
|
|
||||||
|
let sourced = ["!f\u0083\x02\<Esc>z=0"]
|
||||||
|
call writefile(sourced, 'Xsourced', 'b')
|
||||||
|
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S XopenScript -c qa!', #{rows: 6, wait_for_ruler: 0, no_clean: 1})
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for :g/pat/visual to run vi commands in Ex mode
|
" Test for :g/pat/visual to run vi commands in Ex mode
|
||||||
" This used to hang Vim before 8.2.0274.
|
" This used to hang Vim before 8.2.0274.
|
||||||
func Test_Ex_global()
|
func Test_Ex_global()
|
||||||
|
Loading…
Reference in New Issue
Block a user