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 <[email protected]> Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4baff50 commit e5e9b56

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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)