-fix use after free, nicer loop
authorChristian Grothoff <christian@grothoff.org>
Wed, 20 Jun 2012 10:49:24 +0000 (10:49 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 20 Jun 2012 10:49:24 +0000 (10:49 +0000)
src/testbed/testbed_api.c

index fc4b86603ba650225b4e9e98b9f860e7c8501f10..4787ea25a1f433757eddd62f590a7412ef919ef4 100644 (file)
@@ -325,9 +325,12 @@ GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_Controller *controller)
 
   if (NULL != controller->th)
     GNUNET_CLIENT_notify_transmit_ready_cancel (controller->th);
 for (mq_entry = controller->mq_head; /* Clear the message queue */
-       NULL != mq_entry; mq_entry = controller->mq_head)
+ /* Clear the message queue */
+  while (NULL != (mq_entry = controller->mq_head))
   {
+    GNUNET_CONTAINER_DLL_remove (controller->mq_head,
+                                controller->mq_tail,
+                                mq_entry);
     GNUNET_free (mq_entry->msg);
     GNUNET_free (mq_entry);
   }