mercurial/bdiff.c
changeset 30321 d500ddae7494
parent 29541 9631ff5ebbeb
child 30331 e1d6aa0e4c3a
--- a/mercurial/bdiff.c	Sat Nov 05 23:41:52 2016 -0700
+++ b/mercurial/bdiff.c	Sun Nov 06 00:37:50 2016 -0700
@@ -31,9 +31,11 @@
 
 	/* count the lines */
 	i = 1; /* extra line for sentinel */
-	for (p = a; p < a + len; p++)
-		if (*p == '\n' || p == plast)
+	for (p = a; p < plast; p++)
+		if (*p == '\n')
 			i++;
+	if (p == plast)
+		i++;
 
 	*lr = l = (struct bdiff_line *)malloc(sizeof(struct bdiff_line) * i);
 	if (!l)