git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] bisect: avoid signed integer overflow

From
John Keeping <john@keeping.me.uk>
Date
Apr 2, 2013, 19:50 UTC
Message-ID
<0cb4456948b0874a1cedc5679a7b23b82e755e94.1364931627.git.john@keeping.me.uk>
In-Reply-To
<cover.1364931627.git.john@keeping.me.uk>
Signed-off-by: John Keeping <john@keeping.me.uk>
---
 bisect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bisect.c b/bisect.c
index bd1b7b5..0d33c6f 100644
--- a/bisect.c
+++ b/bisect.c
@@ -526,7 +526,7 @@ struct commit_list *filter_skipped(struct commit_list *list,
  * for this application.
  */
 static int get_prn(int count) {
-	count = count * 1103515245 + 12345;
+	count = ((unsigned) count) * 1103515245 + 12345;
 	return ((unsigned)(count/65536) % PRN_MODULO);
 }
 
-- 
1.8.2.540.gf023cfe
Previous: John KeepingNext: Junio C Hamano
Message 7 of 9 in “Fixes for undefined behaviour”
  1. 0/2 Fixes for undefined behaviourJohn Keeping, Apr 2, 2013
  2. 1/2 diffcore-break: don't divide by zeroJohn Keeping, Apr 2, 2013
  3. Junio C HamanoApr 2, 2013
  4. John KeepingApr 2, 2013
  5. Junio C HamanoApr 2, 2013
  6. diffcore-break: don't divide by zeroJohn Keeping, Apr 3, 2013
  7. 2/2 bisect: avoid signed integer overflowJohn Keeping, Apr 2, 2013
  8. Junio C HamanoApr 2, 2013
  9. John KeepingApr 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.