From: Jeff King Date: Tue, 4 Aug 2020 07:50:17 +0000 (-0400) Subject: revision: avoid leak when preparing bloom filter for "/" X-Git-Tag: v2.29.0-rc0~183^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=398e659e1ec60501d67a0f3cb1a1052c6e50038c;p=thirdparty%2Fgit.git revision: avoid leak when preparing bloom filter for "/" If we're given an empty pathspec, we refuse to set up bloom filters, as described in f3c2a36810 (revision: empty pathspecs should not use Bloom filters, 2020-07-01). But before the empty string check, we drop any trailing slash by allocating a new string without it. So a pathspec consisting only of "/" will allocate that string, but then still cause us to bail, leaking the new string. Let's make sure to free it. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/revision.c b/revision.c index 5ed86e4524..b80868556b 100644 --- a/revision.c +++ b/revision.c @@ -702,6 +702,7 @@ static void prepare_to_use_bloom_filter(struct rev_info *revs) len = strlen(path); if (!len) { revs->bloom_filter_settings = NULL; + free(path_alloc); return; }