[PATCH v2 5/9] Smartcard: Don't pass pipe item to _init_send_data()

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

 



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

_______________________________________________
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]