mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
hopefully a more correct implementation
This commit is contained in:
parent
42ba67eb4b
commit
814e2ddfe9
1 changed files with 2 additions and 6 deletions
|
@ -74,12 +74,10 @@ Q_snprintfz (char *dest, size_t size, const char *fmt, ...)
|
|||
int len;
|
||||
va_list argptr;
|
||||
|
||||
if (!size)
|
||||
return -1;
|
||||
va_start (argptr, fmt);
|
||||
len = _vsnprintf (dest, size - 1, fmt, argptr);
|
||||
va_end (argptr);
|
||||
if (len < 0) // the string didn't fit into the buffer
|
||||
if (len < 0 && size) // the string didn't fit into the buffer
|
||||
dest[size - 1] = 0;
|
||||
return len;
|
||||
}
|
||||
|
@ -89,11 +87,9 @@ Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
|
|||
{
|
||||
int len;
|
||||
|
||||
if (!size)
|
||||
return -1;
|
||||
len = _vsnprintf (dest, size - 1, fmt, argptr);
|
||||
|
||||
if (len < 0) // the string didn't fit into the buffer
|
||||
if (len < 0 && size) // the string didn't fit into the buffer
|
||||
dest[size - 1] = 0;
|
||||
return len;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue