From e5e9b56528294e9455d22d1abb21ad32f098a1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 24 Mar 2012 16:18:46 +0100 Subject: 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 diff --git a/combine-diff.c b/combine-diff.c index 9445e86..45221f8 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; -- cgit v0.10.2-6-g49f6