Patch 8.2.5063
Problem:    Error for a command may go over the end of IObuff.
Solution:   Truncate the message.
Files:      src/ex_docmd.c, src/testdir/test_cmdline.vim


*** ../vim-8.2.5062/src/ex_docmd.c      2022-05-28 14:25:32.127084455 +0100
--- src/ex_docmd.c      2022-06-06 15:35:30.795751057 +0100
***************
*** 3441,3449 ****
      static void
  append_command(char_u *cmd)
  {
!     char_u *s = cmd;
!     char_u *d;
  
      STRCAT(IObuff, ": ");
      d = IObuff + STRLEN(IObuff);
      while (*s != NUL && d - IObuff + 5 < IOSIZE)
--- 3441,3457 ----
      static void
  append_command(char_u *cmd)
  {
!     size_t  len = STRLEN(IObuff);
!     char_u  *s = cmd;
!     char_u  *d;
  
+     if (len > IOSIZE - 100)
+     {
+       // Not enough space, truncate and put in "...".
+       d = IObuff + IOSIZE - 100;
+       d -= mb_head_off(IObuff, d);
+       STRCPY(d, "...");
+     }
      STRCAT(IObuff, ": ");
      d = IObuff + STRLEN(IObuff);
      while (*s != NUL && d - IObuff + 5 < IOSIZE)
*** ../vim-8.2.5062/src/testdir/test_cmdline.vim        2022-06-01 
12:31:05.194803595 +0100
--- src/testdir/test_cmdline.vim        2022-06-06 15:35:07.791776771 +0100
***************
*** 3413,3416 ****
--- 3413,3421 ----
    call assert_equal('yes', caught)
  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-8.2.5062/src/version.c       2022-06-06 10:06:57.807633769 +0100
--- src/version.c       2022-06-06 15:22:46.228653016 +0100
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     5063,
  /**/

-- 
Q: What do you call a fish without an eye?
A: fsh!
Q: What do you call a deer with no eyes?
A: no eye deer.
Q: What do you call a deer with no eyes and no legs?
A: still no eye deer.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220606143857.B56991C292E%40moolenaar.net.

Raspunde prin e-mail lui