bdiff.c: use unsigned arithmetic for hash computation
authorMarkus F.X.J. Oberhumer <markus@oberhumer.com>
Wed, 23 Mar 2011 02:33:23 +0100
changeset 13731 5d0cdf4ec338
parent 13730 df978f28a259
child 13732 afe9269dccec
bdiff.c: use unsigned arithmetic for hash computation Signed integer overflow is undefined in C.
mercurial/bdiff.c
--- a/mercurial/bdiff.c	Wed Mar 23 02:33:22 2011 +0100
+++ b/mercurial/bdiff.c	Wed Mar 23 02:33:23 2011 +0100
@@ -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;
 }