]> git.ipfire.org Git - thirdparty/git.git/commit
pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed
authorLidong Yan <502024330056@smail.nju.edu.cn>
Mon, 12 May 2025 12:22:10 +0000 (12:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 May 2025 17:58:35 +0000 (10:58 -0700)
commit7291c2be6a276f8b3693fb7d8dd763cee14c2485
treef9b3168c3a655a8b1d30b46e5185c36ed3ea3998
parent7a1d2bd0a596f42a8a7a68d55577967bb454fec0
pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed

In pack-bitmap.c:load_bitmap_entries_v1, the function `read_bitmap_1`
allocates a bitmap and reads index data into it. However, if any of
the validation checks following the allocation fail, the allocated bitmap
is not freed, resulting in a memory leak. To avoid this, the validation
checks should be performed before the bitmap is allocated.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap.c