[Spice-devel] [PATCH spice-gtk] channel-usbredir: Remove leak of decompressed buffer

Victor Toso victortoso at redhat.com
Thu Jul 11 13:09:31 UTC 2019


Hi,

On Thu, Jul 11, 2019 at 01:58:57PM +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

Nice,
Acked-by: Victor Toso <victortoso at redhat.com>

> ---
>  src/channel-usbredir.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index 76534180..04acf0bd 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -724,6 +724,7 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
>          if (try_handle_compressed_msg(compressed_data_msg, &buf, &size)) {
>              /* uncompressed ok*/
>          } else {
> +            buf = NULL;
>              r = USB_REDIR_ERROR_READ_PARSE;
>          }
>      } else { /* Regular SPICE_MSG_SPICEVMC_DATA msg */
> @@ -733,17 +734,12 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
>      spice_usbredir_channel_lock(channel);
>      if (r == 0)
>          r = spice_usb_backend_read_guest_data(priv->host, buf, size);
> -    if (r != 0) {
> +    if (r != 0 && priv->spice_device != NULL) {
>          SpiceUsbDevice *spice_device = priv->spice_device;
>          device_error_data err_data;
>          gchar *desc;
>          GError *err;
>  
> -        if (spice_device == NULL) {
> -            spice_usbredir_channel_unlock(channel);
> -            return;
> -        }
> -
>          desc = spice_usb_device_get_description(spice_device, NULL);
>          err = spice_usb_backend_get_error_details(r, desc);
>          g_free(desc);
> @@ -764,6 +760,9 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
>      } else {
>          spice_usbredir_channel_unlock(channel);
>      }
> +    if (spice_msg_in_type(in) == SPICE_MSG_SPICEVMC_COMPRESSED_DATA) {
> +        g_free(buf);
> +    }
>  }
>  
>  #else
> -- 
> 2.20.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190711/be6a4db4/attachment.sig>


More information about the Spice-devel mailing list