[PATCH v4 0/2] pack-bitmap: fix memory leak if load_bitmap failed
- From
Lidong Yan via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 25, 2025, 02:43 UTC
- Message-ID
- <pull.1962.v4.git.git.1748140983.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1962.v3.git.git.1748138764.gitgitgadget@gmail.com>
This patch prevents pack-bitmap.c:load_bitmap() from nulling bitmap_git->bitmap when loading failed thus eliminates memory leak. This patch also add a test case in t5310 which use clang leak sanitizer to detect whether leak happens when loading failed.
Lidong Yan (1): pack-bitmap: add load corrupt bitmap test
Taylor Blau (1): pack-bitmap: fix memory leak if load_bitmap() failed
pack-bitmap.c | 94 +++++++++++++++++++++++++++++++---------- pack-bitmap.h | 1 + t/helper/test-bitmap.c | 8 ++++ t/t5310-pack-bitmaps.sh | 27 ++++++++++++ 4 files changed, 107 insertions(+), 23 deletions(-)
base-commit: 845c48a16a7f7b2c44d8cb137b16a4a1f0140229 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1962%2Fbrandb97%2Ffix-pack-bitmap-leak-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1962/brandb97/fix-pack-bitmap-leak-v4 Pull-Request: https://github.com/git/git/pull/1962
Range-diff vs v3:
1: cf87aad7c99 ! 1: b6b3a83a224 pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed
@@ Metadata
Author: Taylor Blau <me@ttaylorr.com>
## Commit message ##
- pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed
+ pack-bitmap: fix memory leak if load_bitmap() failed
After going through the "failed" label, load_bitmap() will return -1,
and its caller (either prepare_bitmap_walk() or prepare_bitmap_git())
2: f5371d7daa9 = 2: 7876d9a9014 pack-bitmap: add load corrupt bitmap test-- gitgitgadget