diff options
| author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2025-05-22 16:55:22 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-22 14:48:37 -0700 |
| commit | 3aa98a61da6e1403081b4dfaa0c644614d228bac (patch) | |
| tree | 06608214889fd81273e01d0d963479dd1a8511fb | |
| parent | f874c0ed90c63276e0ebc445ad6fee5dcbfacb86 (diff) | |
| download | git-3aa98a61da6e1403081b4dfaa0c644614d228bac.tar.gz | |
midx: avoid negative array index
nth_midxed_pack_int_id() returns the index of the pack file in the multi
pack index's list of packfiles that the specified object. The index is
returned as a uint32_t. Storing this in an int will make the index
negative if the most significant bit is set. Fix this by using uint32_t
as the rest of the code does. This is unlikely to be a practical problem
as it requires the multipack index to reference 2^31 packfiles.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | midx-write.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/midx-write.c b/midx-write.c index 8121e96f4f..ba4a94950a 100644 --- a/midx-write.c +++ b/midx-write.c @@ -1566,7 +1566,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla _("Counting referenced objects"), m->num_objects); for (i = 0; i < m->num_objects; i++) { - int pack_int_id = nth_midxed_pack_int_id(m, i); + uint32_t pack_int_id = nth_midxed_pack_int_id(m, i); count[pack_int_id]++; display_progress(progress, i + 1); } @@ -1697,7 +1697,7 @@ static void fill_included_packs_batch(struct repository *r, total_size = 0; for (i = 0; total_size < batch_size && i < m->num_packs; i++) { - int pack_int_id = pack_info[i].pack_int_id; + uint32_t pack_int_id = pack_info[i].pack_int_id; struct packed_git *p = m->packs[pack_int_id]; uint64_t expected_size; |
