bug fix, need va_copy() when reusing a va_list

This commit is contained in:
rlar 2014-04-12 20:37:36 +02:00
parent a9bdfe3b00
commit 03f0ef778f
3 changed files with 15 additions and 2 deletions

View File

@ -304,4 +304,9 @@ void soa_printf(CKTcircuit *ckt, GENinstance *instance, const char *fmt, ...);
#define NG_IGNOREABLE(x) (void)x
#if !defined(va_copy) && defined(_MSC_VER)
#define va_copy(dst, src) ((dst) = (src))
#endif
#endif

View File

@ -939,7 +939,11 @@ sh_vfprintf(FILE *f, const char *fmt, va_list args)
// assert(size > 0);
for (;;) {
nchars = vsnprintf(p, size, fmt, args);
va_list ap;
va_copy(ap, args);
nchars = vsnprintf(p, size, fmt, ap);
va_end(ap);
if(nchars == -1) { // compatibility to old implementations
size *= 2;

View File

@ -2669,7 +2669,11 @@ tcl_vfprintf(FILE *f, const char *fmt, va_list args)
// assert(size > 0);
for (;;) {
nchars = vsnprintf(p + prolog_len, size, fmt, args);
va_list ap;
va_copy(ap, args);
nchars = vsnprintf(p + prolog_len, size, fmt, ap);
va_end(ap);
if(nchars == -1) { /* compatibility to old implementations */
size *= 2;