summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-05-04 15:55:24 +0200
committerJunio C Hamano <gitster@pobox.com>2017-05-08 12:18:19 +0900
commit1a845a2c88e5b72acce33c9719ec36fcd0f9c877 (patch)
tree67101e9289f17325f5a8cef34904b773502f4b7f /compat
parentd2bbb7c2bcf6e77ebfcabf4e12110fe6d5c91de6 (diff)
downloadgit-1a845a2c88e5b72acce33c9719ec36fcd0f9c877.tar.gz
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>
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 3fbfda5978..fe0e3ccd24 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;