From: René Scharfe Date: Thu, 10 Aug 2017 10:23:45 +0000 (+0200) Subject: win32: plug memory leak on realloc() failure in syslog() X-Git-Tag: v2.14.2~29^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=149d8cbb2ebdf3cdc3e40abff9ff7eb8c647715a;p=git win32: plug memory leak on realloc() failure in syslog() If realloc() fails then the original buffer is still valid. Free it before exiting the function. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c index 6c7c9b6053..161978d720 100644 --- a/compat/win32/syslog.c +++ b/compat/win32/syslog.c @@ -43,8 +43,10 @@ void syslog(int priority, const char *fmt, ...) va_end(ap); while ((pos = strstr(str, "%1")) != NULL) { + char *oldstr = str; str = realloc(str, st_add(++str_len, 1)); if (!str) { + free(oldstr); warning_errno("realloc failed"); return; }