From: Jeff King Date: Fri, 13 Oct 2017 00:20:57 GMT Subject: Re: [PATCH] diff.c: increment buffer pointer in all code path Message-ID: <20171013002057.froqi54olmhmah6b@sigill.intra.peff.net> In-Reply-To: <20171013001837.43nx5paeqisbrflq@sigill.intra.peff.net> On Thu, Oct 12, 2017 at 08:18:37PM -0400, Jeff King wrote: > Fix this by entering the conditional only when we actually > see whitespace. We can apply this also to the > IGNORE_WHITESPACE change. That code path isn't buggy > (because it falls through to returning the next > non-whitespace byte), but it makes the logic more clear if > we only bother to look at whitespace flags after seeing that > the next byte is whitespace. I think there actually _is_ a bug in that code path, but it's unrelated to this one. If you have whitespace at the end of the buffer, then we'd advance *cp until it matches *endp, and then return whatever is at *endp (which is nonsense, or probably a NUL) rather than returning "-1". I'm out of time for tonight and not familiar enough with the color-moved code to come up with a reasonable test case quickly, but maybe you can see if that can trigger bad behavior? -Peff