---
 server/smartcard-channel-client.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/server/smartcard-channel-client.c 
b/server/smartcard-channel-client.c
index 347e177..6f39874 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -211,8 +211,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_unref_pipe_item, item);
 }
 
 void smartcard_channel_client_send_error(RedChannelClient *rcc, 
SpiceMarshaller *m, RedPipeItem *item)
-- 
2.7.4

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

Reply via email to