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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <johannes.schindelin@xxxxxx> 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.



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]