X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=compat%2Fsnprintf.c;h=42ea1ac110813bbd16e77cfbc36f16e6a5e9ddb2;hb=c572f491e545f3fe76a966e418139fc9755a910f;hp=e1e0e7543d9414726122c121b7909bf73809a81a;hpb=6c92972d7f5ab247a8cab5e4b88cb281bf201970;p=git.git diff --git a/compat/snprintf.c b/compat/snprintf.c index e1e0e7543..42ea1ac11 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; }