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 <julia.lawall@lip6.fr> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Mar 24, 2012 at 16:18 UTC
e5e9b56528294e9455d22d1abb21ad32f098a1be
1 file changed
+1
-1
combine-diff.c
+1
-1
@@ -414,7 +414,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
414
hunk_begin, j);
415
la = (la + context < cnt + 1) ?
416
(la + context) : cnt + 1;
417
- while (j <= --la) {
417
+ while (la && j <= --la) {
418
if (sline[la].flag & mark) {
419
contin = 1;
420
break;