dup to prevent access after free:
authorChristian Grothoff <christian@grothoff.org>
Thu, 29 Oct 2009 23:23:41 +0000 (23:23 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 29 Oct 2009 23:23:41 +0000 (23:23 +0000)
src/arm/arm_api.c

index 810f2ebe6050c0f17f4eb87364ea7f025f3f75bd..f2d2b293a76b03375a5ba8c0ba65c349ad57ba9b 100644 (file)
@@ -54,7 +54,7 @@ struct GNUNET_ARM_Handle
   /**
    * The configuration that we are using.
    */
-  const struct GNUNET_CONFIGURATION_Handle *cfg;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
 
   /**
    * Scheduler to use.
@@ -87,7 +87,7 @@ GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
   if (client == NULL)
     return NULL;
   ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle));
-  ret->cfg = cfg;
+  ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
   ret->sched = sched;
   ret->client = client;
   return ret;
@@ -104,6 +104,7 @@ GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h)
 {
   if (h->client != NULL)
     GNUNET_CLIENT_disconnect (h->client);
+  GNUNET_CONFIGURATION_destroy (h->cfg);
   GNUNET_free (h);
 }