Re: [PATCH v2 2/3] pack-bitmap.c: avoid uninitialized `pack_int_id` during reuse
- From
Jeff King <peff@peff.net>
- Date
- Jun 11, 2024, 09:11 UTC
- Message-ID
- <20240611091102.GL3248245@coredump.intra.peff.net>
- In-Reply-To
- <a3c28f12020712818060bd50d1483507c9b11556.1718050244.git.me@ttaylorr.com>
On Mon, Jun 10, 2024 at 04:10:53PM -0400, Taylor Blau wrote:
Show 5 quoted lines
> Avoid the uninitialized read by ensuring that the pack_int_id field is > set in the single-pack reuse case by setting it to either the MIDX > preferred pack's pack_int_id, or '0', in the case of single-pack > bitmaps. In the latter case, we never read the pack_int_id field, so > the choice of '0' is arbitrary.
Could we set it to some sentinel value for the single-pack case? If we set it to "-1", then the BUG() added in patch 3 would trigger if we did accidentally try to feed it to the midx code. Assuming you do not have 2^32-1 packs, of course. ;)
I am OK either way, though. And the rest of the patch looked good.
-Peff