Re: trim_common_tail bug?

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

 



Jeff King <peff@xxxxxxxx> writes:

> diff --git a/xdiff-interface.c b/xdiff-interface.c
> index 700def2..eb60e88 100644
> --- a/xdiff-interface.c
> +++ b/xdiff-interface.c
> @@ -124,6 +124,8 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
>  	for (i = 0, recovered = 0; recovered < trimmed && i <= ctx; i++) {
>  		while (recovered < trimmed && ap[recovered] != '\n')
>  			recovered++;
> +		if (recovered < trimmed && ap[recovered] == '\n')
> +			recovered++;
>  	}
>  	a->size -= (trimmed - recovered);
>  	b->size -= (trimmed - recovered);

Shoot.  Thanks for spotting.

Wouldn't it be enough to do:

  	for (i = 0, recovered = 0; recovered < trimmed && i <= ctx; i++) {
		while (recovered < trimmed && ap[recovered++] != '\n')
	        	; /* nothing */
	}

then (warning: I haven't had my coffee yet)?


-
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]

  Powered by Linux