]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Str::vformat() Don't reuse va_args
authorAidan Van Dyk <aidan@ifax.com>
Wed, 7 Oct 2009 13:28:27 +0000 (09:28 -0400)
committerAidan Van Dyk <aidan@ifax.com>
Wed, 7 Oct 2009 13:32:51 +0000 (09:32 -0400)
Use of the va_args is "destructive", and you need to use a copy
if you intend to re-use it.

libhylafax/Str.c++

index 64638151b86fb7cd833090c2416cc7557bd43ae8..3e60c51fe59206d4e2fdd833e20b3afc77fa7dcc 100644 (file)
@@ -188,7 +188,10 @@ fxStr::vformat(const char* fmt, va_list ap)
        if (len)
            size *= 2;
        tmp = (char*)realloc(tmp, size);
-       len = vsnprintf(tmp, size, fmt, ap);
+       va_list ac;
+       va_copy(ac, ap);
+       len = vsnprintf(tmp, size, fmt, ac);
+       va_end(ac);
        fxAssert(len >= 0, "Str::vformat() error in vsnprintf");
     } while (len > size);