Skip to content

Commit

Permalink
combine-diff: fix loop index underflow
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and gitster committed Mar 26, 2012
1 parent 4baff50 commit e5e9b56
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion combine-diff.c
Expand Up @@ -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;
Expand Down

0 comments on commit e5e9b56

Please sign in to comment.