Skip to content

Commit 149d8cb

Browse files
rscharfegitster
authored andcommitted
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>
1 parent 7234152 commit 149d8cb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compat/win32/syslog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ void syslog(int priority, const char *fmt, ...)
4343
va_end(ap);
4444

4545
while ((pos = strstr(str, "%1")) != NULL) {
46+
char *oldstr = str;
4647
str = realloc(str, st_add(++str_len, 1));
4748
if (!str) {
49+
free(oldstr);
4850
warning_errno("realloc failed");
4951
return;
5052
}

0 commit comments

Comments
 (0)