[Spice-commits] src/channel-usbredir.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 11 13:20:30 UTC 2019


 src/channel-usbredir.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 8414e1b023a25394f874444bac7ed4a734404e70
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jun 3 14:09:18 2019 +0100

    channel-usbredir: Remove leak of decompressed buffer
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index 7653418..04acf0b 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


More information about the Spice-commits mailing list