Thread (1 message) 1 message, 1 author, 2016-07-11

Re: [PATCH 2/2] diff: fix a double off-by-one with --ignore-space-at-eol

From: Junio C Hamano <hidden>
Date: 2016-07-11 19:01:47

Johannes Schindelin [off-list ref] writes:
quoted hunk
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.


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help