Fix open port, copy handlers for use on incoming channels
authorBart Polot <bart.polot+voyager@gmail.com>
Wed, 8 Feb 2017 18:41:41 +0000 (19:41 +0100)
committerBart Polot <bart.polot+voyager@gmail.com>
Wed, 8 Feb 2017 18:41:41 +0000 (19:41 +0100)
src/cadet/cadet_api.c

index e20796d174aeb7c76a307848bca352f10c002e3b..7b9ac62b388c7aae0d103764363308007d71c0ff 100644 (file)
@@ -2538,7 +2538,16 @@ GNUNET_CADET_open_porT (struct GNUNET_CADET_Handle *h,
   p->cls = connects_cls;
   p->window_changes = window_changes;
   p->disconnects = disconnects;
-  p->handlers = handlers;
+  if (NULL != handlers)
+  {
+    unsigned int i;
+    for (i=0;NULL != handlers[i].cb; i++) ;
+    p->handlers = GNUNET_new_array (i + 1,
+                                    struct GNUNET_MQ_MessageHandler);
+    GNUNET_memcpy ((struct GNUNET_MQ_MessageHandler *) p->handlers,
+                   handlers,
+                   i * sizeof (struct GNUNET_MQ_MessageHandler));
+  }
 
   GNUNET_assert (GNUNET_OK ==
                 GNUNET_CONTAINER_multihashmap_put (h->ports,