summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-08-22 10:29:16 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-08-22 10:29:16 -0700
commitb8feb6ef2300c7e36c9888ec87571aff0e5f495b (patch)
treeedecac89b8d8aab28cfa4604d023edc1aec630bd
parentMerge branch 'rs/unpack-entry-leakfix' (diff)
parentwin32: plug memory leak on realloc() failure in syslog() (diff)
downloadtgif-b8feb6ef2300c7e36c9888ec87571aff0e5f495b.tar.xz
Merge branch 'rs/win32-syslog-leakfix'
Memory leak in an error codepath has been plugged. * rs/win32-syslog-leakfix: win32: plug memory leak on realloc() failure in syslog()
-rw-r--r--compat/win32/syslog.c2
1 files changed, 2 insertions, 0 deletions
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;
}