mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.5063: error for a command may go over the end of IObuff (#19260)
Problem: Error for a command may go over the end of IObuff.
Solution: Truncate the message.
44a3f3353e
This commit is contained in:
parent
664efa497e
commit
4ffe5d0189
@ -2904,9 +2904,16 @@ int checkforcmd(char **pp, char *cmd, int len)
|
|||||||
/// invisible otherwise.
|
/// invisible otherwise.
|
||||||
static void append_command(char *cmd)
|
static void append_command(char *cmd)
|
||||||
{
|
{
|
||||||
|
size_t len = STRLEN(IObuff);
|
||||||
char *s = cmd;
|
char *s = cmd;
|
||||||
char *d;
|
char *d;
|
||||||
|
|
||||||
|
if (len > IOSIZE - 100) {
|
||||||
|
// Not enough space, truncate and put in "...".
|
||||||
|
d = (char *)IObuff + IOSIZE - 100;
|
||||||
|
d -= utf_head_off(IObuff, (const char_u *)d);
|
||||||
|
STRCPY(d, "...");
|
||||||
|
}
|
||||||
STRCAT(IObuff, ": ");
|
STRCAT(IObuff, ": ");
|
||||||
d = (char *)IObuff + STRLEN(IObuff);
|
d = (char *)IObuff + STRLEN(IObuff);
|
||||||
while (*s != NUL && (char_u *)d - IObuff + 5 < IOSIZE) {
|
while (*s != NUL && (char_u *)d - IObuff + 5 < IOSIZE) {
|
||||||
|
@ -1361,4 +1361,9 @@ func Test_recursive_register()
|
|||||||
call assert_equal('yes', caught)
|
call assert_equal('yes', caught)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_long_error_message()
|
||||||
|
" the error should be truncated, not overrun IObuff
|
||||||
|
silent! norm Q00000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user