[PATCH] don't return uninitialized memory from bdiff.blocks()

Erling Ellingsen erlingalf at gmail.com
Tue Feb 20 15:32:01 CST 2007


# HG changeset patch
# User Erling Ellingsen <erlingalf at gmail.com>
# Date 1172006416 -3600
# Node ID 6cb1305943a62537f9929fcb699ef51aff3a23f9
# Parent  e2ed92f4c0f759fe2a2803853bfcb92f135d85c5
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,

diff -r e2ed92f4c0f7 -r 6cb1305943a6 mercurial/bdiff.c
--- a/mercurial/bdiff.c	Sat Feb 17 04:50:06 2007 -0200
+++ b/mercurial/bdiff.c	Tue Feb 20 22:20:16 2007 +0100
@@ -255,8 +255,8 @@ static struct hunklist diff(struct line
 	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++;
 	}


More information about the Mercurial-devel mailing list