From f20366a0ad32fe1201308f89536fbb989e281f88 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 19 Apr 2017 16:16:44 +0200 Subject: [PATCH] mingw: avoid memory leak when splitting PATH In the (admittedly, concocted) case that PATH consists only of path delimiters, we would leak the duplicated string. Reported by Coverity. Signed-off-by: Johannes Schindelin --- compat/mingw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index 0ec4d55731..ff53808ebe 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1166,8 +1166,10 @@ static char **get_path_split(void) ++n; } } - if (!n) + if (!n) { + free(envpath); return NULL; + } ALLOC_ARRAY(path, n + 1); p = envpath;