Commit b7566f0
committed
pack-bitmap: handle missing bitmap for base MIDX
open_midx_bitmap_1() calls prepare_midx_bitmap_git() to load the
bitmap for a chained MIDX's base layer. If the base MIDX does not
have an associated bitmap file (e.g., it was not generated, or
was deleted by gc), prepare_midx_bitmap_git() returns NULL. The
return value is stored in bitmap_git->base and immediately
dereferenced on the next line to read base->base_nr, causing a
NULL pointer crash.
This can happen in practice with incremental MIDX chains: the
base MIDX may have been written without --write-bitmap-index, or
the bitmap may have been pruned while the incremental layer's
bitmap still references it.
Check the return value and go to the cleanup label (which unmaps
the current bitmap and returns -1) so the caller falls back to
non-bitmap object enumeration, matching the handling of other
bitmap loading failures in the same function (lines 502, 507,
511, 517).
Pointed out by Coverity.
Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 6d4740c commit b7566f0
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
526 | 530 | | |
527 | 531 | | |
528 | 532 | | |
| |||
0 commit comments