git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test_bitmap_hashes(): handle repository without bitmaps
@ 2021-11-05  9:01 Jeff King
  2021-11-05 18:52 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2021-11-05  9:01 UTC (permalink / raw)
  To: git; +Cc: Taylor Blau, Junio C Hamano

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>
---
This is new in the v2.34.0 cycle, but it's so low impact it doesn't
matter much if we ship with the bug. OTOH, it's pretty low-risk since it
is only run by the test suite.

 pack-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pack-bitmap.c b/pack-bitmap.c
index a56ceb9441..f772d3cb7f 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1759,7 +1759,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++) {
-- 
2.34.0.rc1.634.g85d556ea55

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-08 22:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-05  9:01 [PATCH] test_bitmap_hashes(): handle repository without bitmaps Jeff King
2021-11-05 18:52 ` Junio C Hamano
2021-11-05 19:11   ` Taylor Blau
2021-11-05 23:29     ` Jeff King
2021-11-06  4:08     ` move some test-tools to 'unstable plumbing' built-ins (was: [PATCH] test_bitmap_hashes(): handle repository without bitmaps) Ævar Arnfjörð Bjarmason
2021-11-07 17:06       ` Taylor Blau
2021-11-08 19:16         ` move some test-tools to 'unstable plumbing' built-ins Junio C Hamano
2021-11-08 20:19           ` Ævar Arnfjörð Bjarmason
2021-11-08 22:06             ` Taylor Blau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).