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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 4, 2017 at 15:55 UTC
1a845a2c88e5b72acce33c9719ec36fcd0f9c877
1 file changed
+3
-1
compat/mingw.c
+3
-1
@@ -961,8 +961,10 @@ static char **get_path_split(void)
961
++n;
962
}
963
}
964
- if (!n)
964
+ if (!n) {
965
+ free(envpath);
966
return NULL;
967
+ }
968
969
ALLOC_ARRAY(path, n + 1);
970
p = envpath;