mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.1.2149: crash when running out of memory very early
Problem: Crash when running out of memory very early. Solution: Do not use IObuff when it's NULL. (closes #5052)
This commit is contained in:
@@ -355,6 +355,14 @@ int vim_snprintf(char *str, size_t str_m, const char *fmt, ...);
|
|||||||
|
|
||||||
int
|
int
|
||||||
smsg(const char *s, ...)
|
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_list arglist;
|
||||||
|
|
||||||
@@ -363,9 +371,18 @@ smsg(const char *s, ...)
|
|||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
return msg((char *)IObuff);
|
return msg((char *)IObuff);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
smsg_attr(int attr, const char *s, ...)
|
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_list arglist;
|
||||||
|
|
||||||
@@ -374,9 +391,18 @@ smsg_attr(int attr, const char *s, ...)
|
|||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
return msg_attr((char *)IObuff, attr);
|
return msg_attr((char *)IObuff, attr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
smsg_attr_keep(int attr, const char *s, ...)
|
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_list arglist;
|
||||||
|
|
||||||
@@ -385,6 +411,7 @@ smsg_attr_keep(int attr, const char *s, ...)
|
|||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
return msg_attr_keep((char *)IObuff, attr, TRUE);
|
return msg_attr_keep((char *)IObuff, attr, TRUE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -723,8 +750,16 @@ emsg(char *s)
|
|||||||
int
|
int
|
||||||
semsg(const char *s, ...)
|
semsg(const char *s, ...)
|
||||||
{
|
{
|
||||||
/* Skip this if not giving error messages at the moment. */
|
// Skip this if not giving error messages at the moment.
|
||||||
if (!emsg_not_now())
|
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_list ap;
|
||||||
|
|
||||||
@@ -733,7 +768,8 @@ semsg(const char *s, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
return emsg_core(IObuff);
|
return emsg_core(IObuff);
|
||||||
}
|
}
|
||||||
return TRUE; /* no error messages at the moment */
|
}
|
||||||
|
return TRUE; // no error messages at the moment
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -763,6 +799,14 @@ iemsg(char *s)
|
|||||||
siemsg(const char *s, ...)
|
siemsg(const char *s, ...)
|
||||||
{
|
{
|
||||||
if (!emsg_not_now())
|
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_list ap;
|
||||||
|
|
||||||
@@ -771,6 +815,7 @@ siemsg(const char *s, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
emsg_core(IObuff);
|
emsg_core(IObuff);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
# ifdef ABORT_ON_INTERNAL_ERROR
|
# ifdef ABORT_ON_INTERNAL_ERROR
|
||||||
abort();
|
abort();
|
||||||
# endif
|
# endif
|
||||||
@@ -3505,10 +3550,19 @@ give_warning(char_u *message, int hl)
|
|||||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
void
|
void
|
||||||
give_warning2(char_u *message, char_u *a1, int hl)
|
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);
|
vim_snprintf((char *)IObuff, IOSIZE, (char *)message, a1);
|
||||||
give_warning(IObuff, hl);
|
give_warning(IObuff, hl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2149,
|
||||||
/**/
|
/**/
|
||||||
2148,
|
2148,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user