diff --git a/compat/snprintf.c b/compat/snprintf.c index 480b66f94e..bddfa5cdde 100644 --- a/compat/snprintf.c +++ b/compat/snprintf.c @@ -16,8 +16,11 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) int ret; ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap); - if (ret != -1) + if (ret != -1) { + /* Windows does not NUL-terminate if result fits exactly */ + str[ret] = 0; return ret; + } s = NULL; if (maxsize < 128)