[Spice-devel] [PATCH spice-gtk 6/6] channel: don't call memcpy with NULL dest
Frediano Ziglio
fziglio at redhat.com
Fri Aug 11 11:19:14 UTC 2017
>
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>
> If ncaps == 0, the array will be NULL after set_size().
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
> src/spice-channel.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 642e829..b6141cd 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -1891,6 +1891,9 @@ static void store_caps(const uint8_t *caps_src,
> uint32_t ncaps,
> guint i;
>
> g_array_set_size(caps_dst, ncaps);
> + if (ncaps == 0)
> + return;
> +
> caps = &g_array_index(caps_dst, uint32_t, 0);
> memcpy(caps, caps_src, ncaps * sizeof(uint32_t));
>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Frediano
More information about the Spice-devel
mailing list