Skip to content

Commit 398e659

Browse files
peffgitster
authored andcommitted
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 f3c2a36 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd9a631 commit 398e659

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

revision.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ static void prepare_to_use_bloom_filter(struct rev_info *revs)
702702
len = strlen(path);
703703
if (!len) {
704704
revs->bloom_filter_settings = NULL;
705+
free(path_alloc);
705706
return;
706707
}
707708

0 commit comments

Comments
 (0)