[PATCH v9 01/15] Do not duplicate NULL in xstrdup

Dmitry V. Levin ldv at altlinux.org
Thu Aug 24 17:41:42 UTC 2017


On Thu, Aug 24, 2017 at 06:19:39PM +0700, Nikolay Marchuk wrote:
> ---
>  xmalloc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/xmalloc.c b/xmalloc.c
> index 45ff57b1..b77f6910 100644
> --- a/xmalloc.c
> +++ b/xmalloc.c
> @@ -91,6 +91,9 @@ xreallocarray(void *ptr, size_t nmemb, size_t size)
>  char *
>  xstrdup(const char *str)
>  {
> +	if (!str)
> +		return NULL;
> +
>  	char *p = strdup(str);
>  
>  	if (!p)

The commit message is misleading and incomplete.
The rationale given by Eugene is lost.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170824/05aad5d8/attachment.bin>


More information about the Strace-devel mailing list