Community
Participate
Working Groups
The str_fmt_exception() function is based on the vsnprintf(). With Visual, the vsnprintf() could return a negative value -1 when the output was truncated. According to the Unix man page, it could be the case too, depending on the glibc version. while (1) { buf = (char *)loc_realloc(buf, len); va_start(vaList, fmt); n = vsnprintf(buf, len, fmt, vaList); va_end(vaList); >>> if (n < (int)len) break; <<< len = n + 1; } As suggest into the Unix man page of the vsnprintf() example, The condition to exit the loop would be : if (n > -1 && n < size) break;
I've changed the code to be similar to set_fmt_errno() function code. "if (n > -1 && n < size) break;" would not work - it would cause infinite loop. Fixed.