]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5319-multi-pack-index.sh
delta-islands: fix segfault when freeing island marks
authorPatrick Steinhardt <ps@pks.im>
Thu, 16 Feb 2023 10:29:48 +0000 (11:29 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Feb 2023 17:15:04 +0000 (09:15 -0800)
commit6eb095d78790d0d6cbad2186685dad4e7ba2e3de
treedf35bec5a0cd400748d759ade135b07fd0661207
parent647982bb7171b2409f2a90da245b8a31913f930f
delta-islands: fix segfault when freeing island marks

In 647982bb71 (delta-islands: free island_marks and bitmaps, 2023-02-03)
we have introduced logic to free `island_marks` in order to reduce heap
memory usage in git-pack-objects(1). This commit is causing segfaults in
the case where this Git command does not load delta islands at all, e.g.
when reading object IDs from standard input. One such crash can be hit
when using repacking multi-pack-indices with delta islands enabled.

The root cause of this bug is that we unconditionally dereference the
`island_marks` variable even in the case where it is a `NULL` pointer,
which is fixed by making it conditional. Note that we still leave the
logic in place to set the pointer to `-1` to detect use-after-free bugs
even when there are no loaded island marks at all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
delta-islands.c
t/t5319-multi-pack-index.sh