Make Q_vsnprintf() more standard conform in bg_lib.c, patch by devhc

This commit is contained in:
Thilo Schulz 2011-02-09 01:31:26 +00:00
parent 3b40467599
commit 476e35f50e

View file

@ -1740,13 +1740,8 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
break; /* some picky compilers need this */
}
}
if (buffer != NULL)
{
if (currlen < maxlen - 1)
if (maxlen > 0)
buffer[currlen] = '\0';
else
buffer[maxlen - 1] = '\0';
}
return total;
}
@ -2069,8 +2064,6 @@ static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
int Q_vsnprintf(char *str, size_t length, const char *fmt, va_list args)
{
if (str != NULL)
str[0] = 0;
return dopr(str, length, fmt, args);
}