]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use va_copy() in pure-windows version of tor_asprintf().
authorNick Mathewson <nickm@torproject.org>
Tue, 8 Nov 2016 23:44:06 +0000 (18:44 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 8 Nov 2016 23:44:06 +0000 (18:44 -0500)
It's not okay to use the same varargs list twice, and apparently
some windows build environments produce code here that would leave
tor_asprintf() broken. Fix for bug 20560; bugfix on 0.2.2.11-alpha
when tor_asprintf() was introduced.

changes/bug20560 [new file with mode: 0644]
src/common/compat.c

diff --git a/changes/bug20560 b/changes/bug20560
new file mode 100644 (file)
index 0000000..43d605b
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (portability):
+    - Run correctly when built on Windows build environments that require
+      _vcsprintf(). Fixes bug 20560; bugfix on 0.2.2.11-alpha.
+
index 4f2f9778f2aab7bbb6055b8c8bc5a3c8ae5bf700..8d6a491c42e02af3c7768f80537226777d679b37 100644 (file)
@@ -532,7 +532,10 @@ tor_vasprintf(char **strp, const char *fmt, va_list args)
   /* On Windows, _vsnprintf won't tell us the length of the string if it
    * overflows, so we need to use _vcsprintf to tell how much to allocate */
   int len, r;
-  len = _vscprintf(fmt, args);
+  va_list tmp_args;
+  va_copy(tmp_args, args);
+  len = _vscprintf(fmt, tmp_args);
+  va_end(tmp_args);
   if (len < 0) {
     *strp = NULL;
     return -1;