Skip to content

Commit 875da7f

Browse files
peffgitster
authored andcommitted
test_bitmap_hashes(): handle repository without bitmaps
If prepare_bitmap_git() returns NULL (one easy-to-trigger cause being that the repository does not have bitmaps at all), then we'll segfault accessing bitmap_git->hashes: $ t/helper/test-tool bitmap dump-hashes Segmentation fault We should treat this the same as a repository with bitmaps but no name-hashes, and quietly produce an empty output. The later call to free_bitmap_index() in the cleanup label is OK, as it treats a NULL pointer as a noop. This isn't a big deal in practice, as this function is intended for and used only by test-tool. It's probably worth fixing to avoid confusion, but not worth adding coverage for this to the test suite. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 88d915a commit 875da7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pack-bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ int test_bitmap_hashes(struct repository *r)
17481748
struct object_id oid;
17491749
uint32_t i, index_pos;
17501750

1751-
if (!bitmap_git->hashes)
1751+
if (!bitmap_git || !bitmap_git->hashes)
17521752
goto cleanup;
17531753

17541754
for (i = 0; i < bitmap_num_objects(bitmap_git); i++) {

0 commit comments

Comments
 (0)