int len;
for (;;) {
- len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ va_list tap;
+ va_copy(tap, ap);
+ len = vsnprintf(buffer, size, fmt, tap);
/* snprintf should return -1 only in the error case, but older glibcs
* and probably other systems are buggy in this respect and return -1 if