Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compat/snprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
va_list cp;
char *s;
int ret = -1;
int save_errno = errno;

if (maxsize > 0) {
va_copy(cp, ap);
Expand All @@ -33,7 +34,7 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
str[maxsize-1] = 0;
}
if (ret != -1)
return ret;
goto out;

s = NULL;
if (maxsize < 128)
Expand All @@ -52,6 +53,8 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
ret = -1;
}
free(s);
out:
errno = save_errno;
return ret;
}

Expand Down