mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.0.1270: crash when using search stat in narrow screen (#22078)
Problem: Crash when using search stat in narrow screen.
Solution: Check length of message. (closes vim/vim#11921)
a7d36b7320
This commit is contained in:
@@ -2644,7 +2644,12 @@ static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, bool sh
|
|||||||
len += 2;
|
len += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(msgbuf + strlen(msgbuf) - len, t, len);
|
size_t msgbuf_len = strlen(msgbuf);
|
||||||
|
if (len > msgbuf_len) {
|
||||||
|
len = msgbuf_len;
|
||||||
|
}
|
||||||
|
memmove(msgbuf + msgbuf_len - len, t, len);
|
||||||
|
|
||||||
if (dirc == '?' && stat.cur == maxcount + 1) {
|
if (dirc == '?' && stat.cur == maxcount + 1) {
|
||||||
stat.cur = -1;
|
stat.cur = -1;
|
||||||
}
|
}
|
||||||
|
@@ -270,6 +270,29 @@ func Test_searchcount_fails()
|
|||||||
call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
|
call assert_fails('echo searchcount({"pos" : [1, 2, []]})', 'E745:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_search_stat_narrow_screen()
|
||||||
|
" This used to crash Vim
|
||||||
|
let save_columns = &columns
|
||||||
|
try
|
||||||
|
let after =<< trim [CODE]
|
||||||
|
set laststatus=2
|
||||||
|
set columns=16
|
||||||
|
set shortmess-=S showcmd
|
||||||
|
call setline(1, 'abc')
|
||||||
|
call feedkeys("/abc\<CR>:quit!\<CR>")
|
||||||
|
autocmd VimLeavePre * call writefile(["done"], "Xdone")
|
||||||
|
[CODE]
|
||||||
|
|
||||||
|
if !RunVim([], after, '--clean')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call assert_equal("done", readfile("Xdone")[0])
|
||||||
|
call delete('Xdone')
|
||||||
|
finally
|
||||||
|
let &columns = save_columns
|
||||||
|
endtry
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_searchcount_in_statusline()
|
func Test_searchcount_in_statusline()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user