Re: [PATCH] merge-file: correctly find files when called in subdir

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

 



Thomas Rast wrote:

> I was ready to say "you're right" to Bert's suggestion.  So maybe, for
> the sake of foolproof-ness, we should do something like the patch
> below?
> 
> diff --git i/setup.c w/setup.c
> index a3b76de..7c8906d 100644
> --- i/setup.c
> +++ w/setup.c
> @@ -55,7 +55,7 @@
>  	/* don't add prefix to absolute paths, but still replace '\' by '/' */
>  	if (is_absolute_path(arg))
>  		pfx_len = 0;
> -	else
> +	else if (pfx && *pfx)
>  		memcpy(path, pfx, pfx_len);
>  	strcpy(path + pfx_len, arg);
>  	for (p = path + pfx_len; *p; p++)

Yes, please!  But I'd write it as

	if (pfx_len)
		memcpy(...)

and rely on the commit message to explain that this is about the !pfx
case (so callers with pfx_len == 3, !pfx get a nice, quick segfault
instead of heisenbugs from uninitialized data).
--
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]