mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +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;
|
int len;
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
|
||||||
if (!size)
|
|
||||||
return -1;
|
|
||||||
va_start (argptr, fmt);
|
va_start (argptr, fmt);
|
||||||
len = _vsnprintf (dest, size - 1, fmt, argptr);
|
len = _vsnprintf (dest, size - 1, fmt, argptr);
|
||||||
va_end (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;
|
dest[size - 1] = 0;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -89,11 +87,9 @@ Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!size)
|
|
||||||
return -1;
|
|
||||||
len = _vsnprintf (dest, size - 1, fmt, argptr);
|
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;
|
dest[size - 1] = 0;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue