From: Junio C Hamano Date: Mon, 11 Jul 2016 19:01:33 GMT Subject: Re: [PATCH 2/2] diff: fix a double off-by-one with --ignore-space-at-eol Message-ID: In-Reply-To: Johannes Schindelin writes: > diff --git a/xdiff/xutils.c b/xdiff/xutils.c > index 62cb23d..027192a 100644 > --- a/xdiff/xutils.c > +++ b/xdiff/xutils.c > @@ -200,8 +200,10 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) > return 0; > } > } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL) { > - while (i1 < s1 && i2 < s2 && l1[i1++] == l2[i2++]) > - ; /* keep going */ > + while (i1 < s1 && i2 < s2 && l1[i1] == l2[i2]) { > + i1++; > + i2++; > + } > } When we notice l1[i1] and l2[i2] does not match, we want i1 and i2 to stay pointing at that unmatch. The code before this fix however ends up incrementing them before leaving the loop. This breakage seems to come from 2344d47f (diff: fix 2 whitespace issues, 2006-10-12)? That's quite old and it is somewhat surprising that nobody complained. Well spotted. Will queue. Thanks.