[Spice-devel] [PATCH v1 06/10] Smartcard: Don't pass pipe item to _init_send_data()
Jonathon Jongsma
jjongsma at redhat.com
Wed Dec 14 16:36:41 UTC 2016
---
server/smartcard-channel-client.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
index 347e177..aece01b 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -204,6 +204,12 @@ void smartcard_channel_client_on_disconnect(RedChannelClient *rcc)
}
}
+static void marshaller_free_pipe_item(uint8_t *data, void *opaque)
+{
+ RedPipeItem *item = opaque;
+ red_pipe_item_unref(item);
+}
+
void smartcard_channel_client_send_data(RedChannelClient *rcc,
SpiceMarshaller *m,
RedPipeItem *item,
@@ -211,8 +217,12 @@ void smartcard_channel_client_send_data(RedChannelClient *rcc,
{
spice_assert(rcc);
spice_assert(vheader);
- red_channel_client_init_send_data(rcc, SPICE_MSG_SMARTCARD_DATA, item);
- spice_marshaller_add_by_ref(m, (uint8_t*)vheader, sizeof(VSCMsgHeader) + vheader->length);
+ /* NOTE: 'vheader' is assumed to be owned by 'item' so we keep the pipe
+ * item valid until the message is actually sent. */
+ red_pipe_item_ref(item);
+ red_channel_client_init_send_data(rcc, SPICE_MSG_SMARTCARD_DATA, NULL);
+ spice_marshaller_add_by_ref_full(m, (uint8_t*)vheader, sizeof(VSCMsgHeader) + vheader->length,
+ marshaller_free_pipe_item, item);
}
void smartcard_channel_client_send_error(RedChannelClient *rcc, SpiceMarshaller *m, RedPipeItem *item)
--
2.7.4
More information about the Spice-devel
mailing list