--- a/mercurial/bdiff.c Thu Aug 04 13:22:36 2005 -0800
+++ b/mercurial/bdiff.c Thu Aug 04 13:25:59 2005 -0800
@@ -229,7 +229,8 @@
/* allocate and fill arrays */
t = equatelines(a, an, b, bn);
pos = calloc(bn, sizeof(struct pos));
- l.head = l.base = malloc(sizeof(struct hunk) * ((an + bn) / 4 + 2));
+ /* we can't have more matches than lines in the shorter file */
+ l.head = l.base = malloc(sizeof(struct hunk) * ((an<bn ? an:bn) + 1));
if (pos && l.base && t) {
/* generate the matching block list */