[Spice-devel] [PATCH 6/9] common: spice_memdup could accept NULL

Christophe Fergeau cfergeau at redhat.com
Wed Apr 27 04:22:26 PDT 2011


On Tue, Jan 25, 2011 at 07:17:25PM +0100, Marc-André Lureau wrote:
> diff --git a/common/mem.c b/common/mem.c
> index b0a7eb1..4db8a2c 100644
> --- a/common/mem.c
> +++ b/common/mem.c
> @@ -71,6 +71,10 @@ void *spice_memdup(const void *mem, size_t n_bytes)
>  {
>      void *copy;
>  
> +    if (mem == NULL) {
> +        return NULL;
> +    }
> +

I'd rather have an ASSERT(n_bytes == 0) if we do this change so that we
don't allow memdup'ing pointers that are not expected to be NULL.
Do you remember why you needed this? Wasn't it possible to fix the caller
to not pass NULL?

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20110427/63052612/attachment.pgp>


More information about the Spice-devel mailing list