[Spice-devel] [PATCH spice-gtk] RFC: usbredir: fix leaks introduced by lz4 patch
marcandre.lureau at redhat.com
marcandre.lureau at redhat.com
Mon Jul 11 15:16:25 UTC 2016
From: Marc-André Lureau <marcandre.lureau at redhat.com>
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>
---
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);
--
2.9.0
More information about the Spice-devel
mailing list