[PATCH] smartcard: do not keep weak ref when device is NULL

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

 



When a client disconnects, smartcard_channel_client_set_char_device
is called with a NULL "device" argument. In that case there is
no need to take a weak reference to the device.

Without this patch the server complains:
  g_object_add_weak_pointer: assertion 'G_IS_OBJECT (object)' failed

and aborts when a second client attempts to connect.

Signed-off-by: Uri Lublin <uril@xxxxxxxxxx>
---
 server/smartcard-channel-client.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
index 3b3fc27cc..49e765b7c 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -389,8 +389,10 @@ void smartcard_channel_client_set_char_device(SmartCardChannelClient *scc,
     }
 
     scc->priv->smartcard = device;
-    g_object_add_weak_pointer(G_OBJECT(scc->priv->smartcard),
-                              (gpointer*)&scc->priv->smartcard);
+    if (scc->priv->smartcard) {
+        g_object_add_weak_pointer(G_OBJECT(scc->priv->smartcard),
+                                  (gpointer*)&scc->priv->smartcard);
+    }
 }
 
 RedCharDeviceSmartcard* smartcard_channel_client_get_char_device(SmartCardChannelClient *scc)
-- 
2.20.1

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




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