Fix free of NULL pointer
authorBart Polot <bart.polot+voyager@gmail.com>
Tue, 31 Jan 2017 03:22:07 +0000 (04:22 +0100)
committerBart Polot <bart.polot+voyager@gmail.com>
Tue, 31 Jan 2017 03:22:07 +0000 (04:22 +0100)
src/cadet/cadet_api.c

index 3eaa78af86ee00f07897938bd71cd82263d00127..e00203b253f19f5f61aa7c60a9ce661c7ce3c7ab 100644 (file)
@@ -1724,13 +1724,15 @@ GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p)
 {
   struct GNUNET_CADET_PortMessage *msg;
   struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_HashCode *id;
 
   env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
 
-  msg->port = *p->hash;
+  id = NULL != p->hash ? p->hash : &p->id;
+  msg->port = *id;
   GNUNET_MQ_send (p->cadet->mq, env);
-  GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, p->hash, p);
-  GNUNET_free (p->hash);
+  GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, id, p);
+  GNUNET_free_non_null (p->hash);
   GNUNET_free (p);
 }