Rework change to util::vfmt to fix strings getting truncated

This commit is contained in:
Tim Wojtulewicz 2022-10-24 17:01:45 -07:00 committed by Tomer Lev
parent 77c555a3a8
commit 78fb845f63

View file

@ -1620,11 +1620,11 @@ const char* vfmt(const char* format, va_list al)
va_copy(alc, al); va_copy(alc, al);
int n = vsnprintf(buf, buf_len, format, al); int n = vsnprintf(buf, buf_len, format, al);
if ( n < 0 && buf_len < 1024 * 1024 ) if ( n > 0 && buf_len < n )
{ // Not enough room, grow the buffer. { // Not enough room, grow the buffer.
buf_len += 32; buf_len = n + 32;
buf = (char*)safe_realloc(buf, buf_len); buf = (char*)safe_realloc(buf, buf_len);
n = vsnprintf(buf, buf_len, format, al); n = vsnprintf(buf, buf_len, format, alc);
} }
if ( n < 0 ) if ( n < 0 )