aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-07 06:37:54 +0800
committerGitHub <noreply@github.com>2022-07-07 06:37:54 +0800
commit4ffe5d018919d3fbea21e667f09f14b9751f9cd5 (patch)
tree1f6e5546aa35b0c383b592ac75ab4d9382c65d76 /src/nvim/ex_docmd.c
parent664efa497e4e3d79d2e4ab486acbf1471b2389b0 (diff)
downloadrneovim-4ffe5d018919d3fbea21e667f09f14b9751f9cd5.tar.gz
rneovim-4ffe5d018919d3fbea21e667f09f14b9751f9cd5.tar.bz2
rneovim-4ffe5d018919d3fbea21e667f09f14b9751f9cd5.zip
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. https://github.com/vim/vim/commit/44a3f3353e0407e9fffee138125a6927d1c9e7e5
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 18490bd60c..d4fe55392e 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -2904,9 +2904,16 @@ int checkforcmd(char **pp, char *cmd, int len)
/// invisible otherwise.
static void append_command(char *cmd)
{
+ size_t len = STRLEN(IObuff);
char *s = cmd;
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, ": ");
d = (char *)IObuff + STRLEN(IObuff);
while (*s != NUL && (char_u *)d - IObuff + 5 < IOSIZE) {