Patch 8.1.2149
Problem:    Crash when running out of memory very early.
Solution:   Do not use IObuff when it's NULL. (closes #5052)
Files:      src/message.c


*** ../vim-8.1.2148/src/message.c       2019-10-12 17:06:48.798440368 +0200
--- src/message.c       2019-10-14 22:01:29.612929964 +0200
***************
*** 356,389 ****
      int
  smsg(const char *s, ...)
  {
!     va_list arglist;
  
!     va_start(arglist, s);
!     vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
!     va_end(arglist);
!     return msg((char *)IObuff);
  }
  
      int
  smsg_attr(int attr, const char *s, ...)
  {
!     va_list arglist;
  
!     va_start(arglist, s);
!     vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
!     va_end(arglist);
!     return msg_attr((char *)IObuff, attr);
  }
  
      int
  smsg_attr_keep(int attr, const char *s, ...)
  {
!     va_list arglist;
  
!     va_start(arglist, s);
!     vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
!     va_end(arglist);
!     return msg_attr_keep((char *)IObuff, attr, TRUE);
  }
  
  #endif
--- 356,416 ----
      int
  smsg(const char *s, ...)
  {
!     if (IObuff == NULL)
!     {
!       // Very early in initialisation and already something wrong, just
!       // give the raw message so the user at least gets a hint.
!       return msg((char *)s);
!     }
!     else
!     {
!       va_list arglist;
  
!       va_start(arglist, s);
!       vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
!       va_end(arglist);
!       return msg((char *)IObuff);
!     }
  }
  
      int
  smsg_attr(int attr, const char *s, ...)
  {
!     if (IObuff == NULL)
!     {
!       // Very early in initialisation and already something wrong, just
!       // give the raw message so the user at least gets a hint.
!       return msg_attr((char *)s, attr);
!     }
!     else
!     {
!       va_list arglist;
  
!       va_start(arglist, s);
!       vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
!       va_end(arglist);
!       return msg_attr((char *)IObuff, attr);
!     }
  }
  
      int
  smsg_attr_keep(int attr, const char *s, ...)
  {
!     if (IObuff == NULL)
!     {
!       // Very early in initialisation and already something wrong, just
!       // give the raw message so the user at least gets a hint.
!       return msg_attr_keep((char *)s, attr, TRUE);
!     }
!     else
!     {
!       va_list arglist;
  
!       va_start(arglist, s);
!       vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
!       va_end(arglist);
!       return msg_attr_keep((char *)IObuff, attr, TRUE);
!     }
  }
  
  #endif
***************
*** 723,739 ****
      int
  semsg(const char *s, ...)
  {
!     /* Skip this if not giving error messages at the moment. */
      if (!emsg_not_now())
      {
!       va_list ap;
  
!       va_start(ap, s);
!       vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
!       va_end(ap);
!       return emsg_core(IObuff);
      }
!     return TRUE;              /* no error messages at the moment */
  }
  #endif
  
--- 750,775 ----
      int
  semsg(const char *s, ...)
  {
!     // Skip this if not giving error messages at the moment.
      if (!emsg_not_now())
      {
!       if (IObuff == NULL)
!       {
!           // Very early in initialisation and already something wrong, just
!           // give the raw message so the user at least gets a hint.
!           return emsg_core((char_u *)s);
!       }
!       else
!       {
!           va_list ap;
  
!           va_start(ap, s);
!           vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
!           va_end(ap);
!           return emsg_core(IObuff);
!       }
      }
!     return TRUE;              // no error messages at the moment
  }
  #endif
  
***************
*** 764,775 ****
  {
      if (!emsg_not_now())
      {
!       va_list ap;
  
!       va_start(ap, s);
!       vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
!       va_end(ap);
!       emsg_core(IObuff);
      }
  # ifdef ABORT_ON_INTERNAL_ERROR
      abort();
--- 800,820 ----
  {
      if (!emsg_not_now())
      {
!       if (IObuff == NULL)
!       {
!           // Very early in initialisation and already something wrong, just
!           // give the raw message so the user at least gets a hint.
!           emsg_core((char_u *)s);
!       }
!       else
!       {
!           va_list ap;
  
!           va_start(ap, s);
!           vim_vsnprintf((char *)IObuff, IOSIZE, s, ap);
!           va_end(ap);
!           emsg_core(IObuff);
!       }
      }
  # ifdef ABORT_ON_INTERNAL_ERROR
      abort();
***************
*** 3506,3513 ****
      void
  give_warning2(char_u *message, char_u *a1, int hl)
  {
!     vim_snprintf((char *)IObuff, IOSIZE, (char *)message, a1);
!     give_warning(IObuff, hl);
  }
  #endif
  
--- 3551,3567 ----
      void
  give_warning2(char_u *message, char_u *a1, int hl)
  {
!     if (IObuff == NULL)
!     {
!       // Very early in initialisation and already something wrong, just give
!       // the raw message so the user at least gets a hint.
!       give_warning((char_u *)message, hl);
!     }
!     else
!     {
!       vim_snprintf((char *)IObuff, IOSIZE, (char *)message, a1);
!       give_warning(IObuff, hl);
!     }
  }
  #endif
  
*** ../vim-8.1.2148/src/version.c       2019-10-13 21:01:31.058733704 +0200
--- src/version.c       2019-10-14 22:01:42.016880164 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     2149,
  /**/

-- 
Zen Microsystems: we're the om in .commmmmmmmm

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/201910142002.x9EK2h0p012422%40masaka.moolenaar.net.

Raspunde prin e-mail lui