- fix coverity
[oweals/gnunet.git] / src / scalarproduct / gnunet-service-scalarproduct_bob.c
index 79a0e961a5a1d4886425a8f2b89af5e4f1a83eb9..d0a622a36a3d9567675793fe217a50b49b99f335 100644 (file)
@@ -460,6 +460,8 @@ prepare_client_end_notification (struct BobServiceSession *session)
   struct ClientResponseMessage *msg;
   struct GNUNET_MQ_Envelope *e;
 
+  if (NULL == session->client_mq)
+    return; /* no client left to be notified */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending session-end notification with status %d to client for session %s\n",
               session->status,
@@ -497,12 +499,6 @@ cb_channel_destruction (void *cls,
               "Peer disconnected, terminating session %s with peer %s\n",
               GNUNET_h2s (&in->session_id),
               GNUNET_i2s (&in->peer));
-  if (NULL != in->cadet_mq)
-  {
-    GNUNET_MQ_destroy (in->cadet_mq);
-    in->cadet_mq = NULL;
-  }
-  in->channel = NULL;
   if (NULL != (s = in->s))
   {
     if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
@@ -511,6 +507,12 @@ cb_channel_destruction (void *cls,
       prepare_client_end_notification (s);
     }
   }
+  if (NULL != in->cadet_mq)
+  {
+    GNUNET_MQ_destroy (in->cadet_mq);
+    in->cadet_mq = NULL;
+  }
+  in->channel = NULL;
   destroy_cadet_session (in);
 }