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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Aug 10, 2017 at 12:23 UTC 149d8cbb2ebdf3cdc3e40abff9ff7eb8c647715a
1 file changed +2
compat/win32/syslog.c
+2
@@ -43,8 +43,10 @@ void syslog(int priority, const char *fmt, ...)
43 va_end(ap);
44
45 while ((pos = strstr(str, "%1")) != NULL) {
46 + char *oldstr = str;
47 str = realloc(str, st_add(++str_len, 1));
48 if (!str) {
49 + free(oldstr);
50 warning_errno("realloc failed");
51 return;
52 }