From: René Scharfe Date: Sat, 24 Mar 2012 15:18:46 +0000 (+0100) Subject: combine-diff: fix loop index underflow X-Git-Tag: v1.7.10.1~13^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e5e9b56528294e9455d22d1abb21ad32f098a1be?ds=inline;hp=--cc combine-diff: fix loop index underflow If both la and context are zero at the start of the loop, la wraps around and we end up reading from memory far away. Skip the loop in that case instead. Reported-by: Julia Lawall Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- e5e9b56528294e9455d22d1abb21ad32f098a1be diff --git a/combine-diff.c b/combine-diff.c index 9445e86c2f..45221f84a5 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -414,7 +414,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt, hunk_begin, j); la = (la + context < cnt + 1) ? (la + context) : cnt + 1; - while (j <= --la) { + while (la && j <= --la) { if (sline[la].flag & mark) { contin = 1; break;