It is not safe to re-va_start a va_list the way this code was previously
operating. This probably worked by coincidence on platforms like x86-64.
va_start(argp, format);
#ifdef HAVE_VSNPRINTF
- len = vsnprintf((char *)buf, BUFSIZ, format, argp);
+ {
+ va_list argp2;
+ va_copy(argp2, argp);
+ len = vsnprintf((char *)buf, BUFSIZ, format, argp2);
+ va_end(argp2);
+ }
if (len < 0) {
+ va_end(argp);
agerr (AGERR, "gvprintf: %s\n", strerror(errno));
return;
}
* to write the string without truncation.
*/
bp = gmalloc(len + 1);
- va_end(argp);
- va_start(argp, format);
len = vsprintf(bp, format, argp);
}
#else