summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2021-11-05 09:01:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-11-05 18:52:42 (GMT)
commit875da7f061bf141aa6bf2c34afad1cf16d179e17 (patch)
treeaabdba223e775a0b519c8265b8ae161ed084587a /pack-bitmap.c
parent88d915a634b449147855041d44875322de2b286d (diff)
downloadgit-875da7f061bf141aa6bf2c34afad1cf16d179e17.zip
git-875da7f061bf141aa6bf2c34afad1cf16d179e17.tar.gz
git-875da7f061bf141aa6bf2c34afad1cf16d179e17.tar.bz2
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index f47a0a7..b37a3c0 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1748,7 +1748,7 @@ int test_bitmap_hashes(struct repository *r)
struct object_id oid;
uint32_t i, index_pos;
- if (!bitmap_git->hashes)
+ if (!bitmap_git || !bitmap_git->hashes)
goto cleanup;
for (i = 0; i < bitmap_num_objects(bitmap_git); i++) {