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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]