Skip to content

Commit e5e9b56

Browse files
René Scharfegitster
authored andcommitted
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>
1 parent 4baff50 commit e5e9b56

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

combine-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
414414
hunk_begin, j);
415415
la = (la + context < cnt + 1) ?
416416
(la + context) : cnt + 1;
417-
while (j <= --la) {
417+
while (la && j <= --la) {
418418
if (sline[la].flag & mark) {
419419
contin = 1;
420420
break;

0 commit comments

Comments
 (0)