changeset 827 | a61728b58dc0 |
parent 597 | e530637ea060 |
child 836 | 1fe3b14c7044 |
--- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -229,7 +229,8 @@ static struct hunklist diff(struct line /* 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 */