Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: [PATCH v3] do not depend on signed integer overflow

From: Jeff King <hidden>
Date: 2016-06-15 22:49:42

On Tue, Oct 05, 2010 at 12:49:12AM +0200, Erik Faye-Lund wrote:
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help