Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-08-10 13:23:45 +0300
committerJunio C Hamano <gitster@pobox.com>2017-08-10 23:57:52 +0300
commit149d8cbb2ebdf3cdc3e40abff9ff7eb8c647715a (patch)
tree5ae2b1f5eed2b1097b3734a4020bd69dba514c35 /compat/win32
parent7234152e66e52c7601789f6de822bb39590f0595 (diff)
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>
Diffstat (limited to 'compat/win32')
-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;
}