Merge branch 'ps/free-island-marks'

Fix on a previous fix already in 'master'.

* ps/free-island-marks:
  delta-islands: fix segfault when freeing island marks
This commit is contained in:
Junio C Hamano 2023-02-24 22:54:01 -08:00
commit f96dd8c3b5
2 changed files with 23 additions and 5 deletions

View File

@ -517,11 +517,13 @@ void free_island_marks(void)
{
struct island_bitmap *bitmap;
kh_foreach_value(island_marks, bitmap, {
if (!--bitmap->refcount)
free(bitmap);
});
kh_destroy_oid_map(island_marks);
if (island_marks) {
kh_foreach_value(island_marks, bitmap, {
if (!--bitmap->refcount)
free(bitmap);
});
kh_destroy_oid_map(island_marks);
}
/* detect use-after-free with a an address which is never valid: */
island_marks = (void *)-1;

View File

@ -1015,4 +1015,20 @@ test_expect_success 'complains when run outside of a repository' '
grep "not a git repository" err
'
test_expect_success 'repack with delta islands' '
git init repo &&
test_when_finished "rm -fr repo" &&
(
cd repo &&
test_commit first &&
git repack &&
test_commit second &&
git repack &&
git multi-pack-index write &&
git -c repack.useDeltaIslands=true multi-pack-index repack
)
'
test_done