From: Jeff King Date: Tue, 05 Oct 2010 03:43:01 GMT Subject: Re: [PATCH v3] do not depend on signed integer overflow Message-ID: <20101005034301.GA23357@coredump.intra.peff.net> In-Reply-To: <1286232552-5244-1-git-send-email-kusmabite@gmail.com> On Tue, Oct 05, 2010 at 12:49:12AM +0200, Erik Faye-Lund wrote: > diff --git a/builtin/index-pack.c b/builtin/index-pack.c > index 2e680d7..e243d9d 100644 > --- a/builtin/index-pack.c > +++ b/builtin/index-pack.c > @@ -161,7 +161,7 @@ static void use(int bytes) > input_offset += bytes; > > /* make sure off_t is sufficiently large not to wrap */ > - if (consumed_bytes > consumed_bytes + bytes) > + if (signed_add_overflows(consumed_bytes, bytes)) > die("pack too large for current definition of off_t"); > consumed_bytes += bytes; > } FWIW, I find your new version much easier to read, too (that it fixes a bug is just a nice bonus. ;) ). -Peff