[PATCH v2 1/2] pack-bitmap: remove checks before bitmap_free
- From
Lidong Yan via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 30, 2025, 18:14 UTC
- Message-ID
- <d7b7a0e29ec0dc92e491401bc0dacfa15d4af2ad.1748628847.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1977.v2.git.git.1748628846.gitgitgadget@gmail.com>
From: Lidong Yan <502024330056@smail.nju.edu.cn>
In pack-bitmap.c:find_boundary_objects, we build a roots_bitmap and cascade it to cb.base. Only when cascade failed, roots_bitmap is freed otherwise it leaks. Since cascade_pseudo_merges_1() only use roots_bitmap as a mutable reference not takes roots_bitmap's ownership we'd better remove `if(cascade_pseudo_merges_1)` and frees roots_bitmap anyway.
Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> --- pack-bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pack-bitmap.c b/pack-bitmap.c index ac6d62b980c5..8727f316de92 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1363,8 +1363,8 @@ static struct bitmap *find_boundary_objects(struct bitmap_index *bitmap_git, bitmap_set(roots_bitmap, pos); } - if (!cascade_pseudo_merges_1(bitmap_git, cb.base, roots_bitmap)) - bitmap_free(roots_bitmap); + cascade_pseudo_merges_1(bitmap_git, cb.base, roots_bitmap); + bitmap_free(roots_bitmap); } /*
-- gitgitgadget