From: Johannes Schindelin Date: Thu, 04 May 2017 13:55:24 GMT Subject: [PATCH v4 01/25] mingw: avoid memory leak when splitting PATH Message-ID: <1857475d4f75b811f16802daaf1303855e3ea4f1.1493906085.git.johannes.schindelin@gmx.de> In-Reply-To: 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 3fbfda5978b..fe0e3ccd248 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -961,8 +961,10 @@ static char **get_path_split(void) ++n; } } - if (!n) + if (!n) { + free(envpath); return NULL; + } ALLOC_ARRAY(path, n + 1); p = envpath; -- 2.12.2.windows.2.800.gede8f145e06