--- tf5-5.0beta8.orig/src/tfio.c
+++ tf5-5.0beta8/src/tfio.c
@@ -497,6 +497,7 @@
     const conString *Sval;
     int len, min, max, leftjust, stars;
     attr_t attrs = buf->attrs;
+    va_list ap_copy;
 
     if (!(flags & SP_APPEND) && buf->data) Stringtrunc(buf, 0);
     while (*fmt) {
@@ -522,7 +523,9 @@
         case 'x': case 'X': case 'u': case 'o':
         case 'f': case 'e': case 'E': case 'g': case 'G':
         case 'p':
-            vsprintf(tempbuf, spec, ap);
+            va_copy(ap_copy, ap);
+            vsprintf(tempbuf, spec, ap_copy);
+            va_end(ap_copy);
             Stringcat(buf, tempbuf);
             /* eat the arguments used by vsprintf() */
             while (stars--) (void)va_arg(ap, int);
