diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-28 23:32:38 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-28 23:32:38 +0400 |
commit | 7fc1495b1800f5207b634140ed66f7037e7f4bff (patch) | |
tree | 23ade8bb2f4402cb1d142f835840a3a85389c120 /compat | |
parent | f1c12e1b4af2eec4eefff9350b74601b36f51d85 (diff) | |
parent | a9bfbc5b698103b1553e1023c4f77001cc861e79 (diff) |
Merge branch 'jk/maint-snprintf-va-copy' into maint
* jk/maint-snprintf-va-copy:
compat/snprintf: don't look at va_list twice
Diffstat (limited to 'compat')
-rw-r--r-- | compat/snprintf.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compat/snprintf.c b/compat/snprintf.c index e1e0e7543d..42ea1ac110 100644 --- a/compat/snprintf.c +++ b/compat/snprintf.c @@ -19,11 +19,14 @@ #undef vsnprintf int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) { + va_list cp; char *s; int ret = -1; if (maxsize > 0) { - ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap); + va_copy(cp, ap); + ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, cp); + va_end(cp); if (ret == maxsize-1) ret = -1; /* Windows does not NUL-terminate if result fills buffer */ @@ -42,7 +45,9 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) if (! str) break; s = str; - ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap); + va_copy(cp, ap); + ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, cp); + va_end(cp); if (ret == maxsize-1) ret = -1; } |