don't return uninitialized memory from bdiff.blocks()
authorErling Ellingsen <erlingalf@gmail.com>
Tue, 20 Feb 2007 22:20:16 +0100
changeset 4131 1ca664c964e0
parent 4130 178007785be8
child 4132 0d94e4a3ddb4
don't return uninitialized memory from bdiff.blocks() bdiff.blocks() returns a dummy match at the end of both files; the length of that chunk is never set, so it will sometimes contain random heap garbage. There are apparently workarounds for this elsewhere: # bdiff sometimes gives huge matches past eof, this check eats them,
mercurial/bdiff.c
--- a/mercurial/bdiff.c	Mon Feb 19 10:08:59 2007 +0100
+++ b/mercurial/bdiff.c	Tue Feb 20 22:20:16 2007 +0100
@@ -251,8 +251,8 @@
 	if (pos && l.base && t) {
 		/* generate the matching block list */
 		recurse(a, b, pos, 0, an, 0, bn, &l);
-		l.head->a1 = an;
-		l.head->b1 = bn;
+		l.head->a1 = l.head->a2 = an;
+		l.head->b1 = l.head->b2 = bn;
 		l.head++;
 	}