Add a type check to avoid a proxy to skeleton cast to fail
authorFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>
Mon, 6 Aug 2012 11:51:53 +0000 (12:51 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Mon, 6 Aug 2012 13:11:52 +0000 (14:11 +0100)
We use the "consumer" property of the ShutdownClient class to store a
proxy in the NSC code and a skeleton in the NSM dummy code. When
releasing the consumer in shutdown_client_finalize(), we may therefor
not cast to a ShutdownConsumerSkeleton unconditionally; otherwise
the NSM dummy will segfault when releasing ShutdownClient objects.

common/shutdown-client.c

index ea5bc9b..6df5138 100644 (file)
@@ -151,8 +151,9 @@ shutdown_client_finalize (GObject *object)
   /* release the consumer, if we have one */
   if (client->consumer != NULL)
     {
-      g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (client->consumer));
-      g_object_unref (client->consumer);  
+      if (IS_SHUTDOWN_CONSUMER_SKELETON (client->consumer))
+        g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (client->consumer));
+      g_object_unref (client->consumer);
     }
 
   (*G_OBJECT_CLASS (shutdown_client_parent_class)->finalize) (object);