[PATCH] bdiff.c: use unsigned arithmetic for hash computation
Markus F.X.J. Oberhumer
markus at oberhumer.com
Tue Mar 22 20:38:34 CDT 2011
# HG changeset patch
# User Markus F.X.J. Oberhumer <markus at oberhumer.com>
# Date 1300844003 -3600
# Node ID 4a93cf659875e42c736a7b76ad0397cc8e96b90e
# Parent 5828a08f0eb3155e40f6838fa2e557b7fa3cccc5
bdiff.c: use unsigned arithmetic for hash computation
Signed integer overflow is undefined in C.
diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -65,7 +65,8 @@
static int splitlines(const char *a, int len, struct line **lr)
{
- int h, i;
+ unsigned h;
+ int i;
const char *p, *b = a;
const char * const plast = a + len - 1;
struct line *l;
@@ -98,7 +99,8 @@
}
/* set up a sentinel */
- l->h = l->len = 0;
+ l->h = 0;
+ l->len = 0;
l->l = a + len;
return i - 1;
}
More information about the Mercurial-devel
mailing list