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

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

 




Tested with valgrind, looks good.

On 07/11/2016 06:16 PM, marcandre.lureau@xxxxxxxxxx wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

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@xxxxxxxxxx>
Reviewed-by: Snir Sheriber <ssheribe@xxxxxxxxxx>
---
  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);

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




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