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

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu Jul 28 08:59:21 UTC 2016


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

New commits:
commit afc4edb8041520962dd1462f688dcb0f724af52d
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Jul 11 17:32:03 2016 +0200

    misc: code style
    
    Brace on new line for functions, 4 spaces indent, seperate end block
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index 85f16d7..0e7a0b0 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -648,15 +648,16 @@ static void usbredir_free_write_cb_data(uint8_t *data, void *user_data)
 }
 
 #ifdef USE_LZ4
-static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data, int count) {
+static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data, int count)
+{
     SpiceChannelPrivate *c;
     SpiceMsgOut *msg_out_compressed;
     int bound, compressed_data_count;
     uint8_t *compressed_buf;
     SpiceMsgCompressedData compressed_data_msg = {
-            .type = SPICE_DATA_COMPRESSION_TYPE_LZ4,
-            .uncompressed_size = count
-        };
+        .type = SPICE_DATA_COMPRESSION_TYPE_LZ4,
+        .uncompressed_size = count
+    };
 
     c = SPICE_CHANNEL(channel)->priv;
     if (g_socket_get_family(c->sock) == G_SOCKET_FAMILY_UNIX) {
@@ -697,6 +698,7 @@ static int try_write_compress_LZ4(SpiceUsbredirChannel *channel, uint8_t *data,
         spice_msg_out_send(msg_out_compressed);
         return TRUE;
     }
+
     /* if not - free & fallback to sending the message uncompressed */
     g_free(compressed_buf);
     return FALSE;
commit 8cc459e054886bb8ef8495b401e7dd647a7c1260
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Jul 11 17:12:35 2016 +0200

    usbredir: fix leaks introduced by lz4 patch
    
    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.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Reviewed-by: Snir Sheriber <ssheribe at redhat.com>

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);


More information about the Spice-commits mailing list