[Spice-devel] [PATCH spice-gtk] RFC: usbredir: fix leaks introduced by lz4 patch

Victor Toso lists at victortoso.com
Tue Jul 12 08:59:39 UTC 2016


Hi,

On Mon, Jul 11, 2016 at 05:16:25PM +0200, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>
> While reviewing lz4 patch, I found that there are potential leaks. This
> is untested, fyi. It would be nice if someone could confirm with running
> ASAN for example.
>

Yes, thanks. This was my mistake as I changed the malloc function before
pushing. I'll double check and let you know.

> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  src/channel-usbredir.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index 9c71c07..85f16d7 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -692,13 +692,13 @@ static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data,
>          spice_marshaller_add_ref_full(msg_out_compressed->marshaller,
>                                        compressed_data_msg.compressed_data,
>                                        compressed_data_count,
> -                                      usbredir_free_write_cb_data,
> +                                      (spice_marshaller_item_free_func)g_free,
>                                        channel);
>          spice_msg_out_send(msg_out_compressed);
>          return TRUE;
>      }
>      /* if not - free & fallback to sending the message uncompressed */
> -    free(compressed_buf);
> +    g_free(compressed_buf);
>      return FALSE;
>  }
>  #endif
> @@ -709,8 +709,10 @@ static int usbredir_write_callback(void *user_data, uint8_t *data, int count)
>      SpiceMsgOut *msg_out;
>  
>  #ifdef USE_LZ4
> -    if (try_write_compress_LZ4(channel, data, count))
> +    if (try_write_compress_LZ4(channel, data, count)) {
> +        usbredirhost_free_write_buffer(channel->priv->host, data);
>          return count;
> +    }
>  #endif
>      msg_out = spice_msg_out_new(SPICE_CHANNEL(channel),
>                                  SPICE_MSGC_SPICEVMC_DATA);
> -- 
> 2.9.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list