Re: [PATCH] index-pack: fix truncation of off_t in comparison
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jun 4, 2015, 13:10 UTC
- Message-ID
- <CACsJy8BUEcduXf3LCbwGnJRYNb4s1KEKj_hwdo0qCtJoS4SgFw@mail.gmail.com>
- In-Reply-To
- <20150604123541.GA8888@peff.net>
On Thu, Jun 4, 2015 at 7:35 PM, Jeff King <peff@peff.net> wrote:
Show 13 quoted lines
> Commit c6458e6 (index-pack: kill union delta_base to save
> memory, 2015-04-18) refactored the comparison functions used
> in sorting and binary searching our delta list. The
> resulting code does something like:
>
> int cmp_offsets(off_t a, off_t b)
> {
> return a - b;
> }
>
> This works most of the time, but produces nonsensical
> results when the difference between the two offsets is
> larger than what can be stored in an "int".Ugh.. thanks for fixing this. Too bad neither gcc, clang or coverity spotted this.
-- Duy