]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: avoid leak when preparing bloom filter for "/"
authorJeff King <peff@peff.net>
Tue, 4 Aug 2020 07:50:17 +0000 (03:50 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Aug 2020 16:31:57 +0000 (09:31 -0700)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 5ed86e45241aaaf26bf0010c9f6c95e41be9b92c..b80868556b4797f50b4e3e311fdaf8d824615ddc 100644 (file)
@@ -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;
        }