Browse Source

bug fix, need va_copy() when reusing a va_list

pre-master-46
rlar 12 years ago
parent
commit
03f0ef778f
  1. 5
      src/include/ngspice/ngspice.h
  2. 6
      src/sharedspice.c
  3. 6
      src/tclspice.c

5
src/include/ngspice/ngspice.h

@ -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

6
src/sharedspice.c

@ -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;

6
src/tclspice.c

@ -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;

Loading…
Cancel
Save