summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-08 18:44:06 -0500
committerNick Mathewson <nickm@torproject.org>2016-11-08 18:44:06 -0500
commit286fa94064dcc6d1b260bec77de052274e3c4403 (patch)
treee013b14f0c604f10af6751016ddb96bb29d04b04 /src/common/compat.c
parent74e84b7eb7ecde8aaa195a7388af0d8dde5df8a9 (diff)
downloadtor-286fa94064dcc6d1b260bec77de052274e3c4403.tar.gz
tor-286fa94064dcc6d1b260bec77de052274e3c4403.zip
Use va_copy() in pure-windows version of tor_asprintf().
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.
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 4f2f9778f2..8d6a491c42 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -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;