-fix use after free on shutdown
authorChristian Grothoff <christian@grothoff.org>
Mon, 14 May 2012 19:15:04 +0000 (19:15 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 14 May 2012 19:15:04 +0000 (19:15 +0000)
src/transport/test_transport_api_restart_1peer.c

index b414805d80afd32d91add97e9a57739486091699..d01d9e4320b415403709a8fd334daf556e4f9ce4 100644 (file)
@@ -112,7 +112,9 @@ end ()
   th = NULL;
 
   GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+  p1 = NULL;
   GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+  p2 = NULL;
 }
 
 static void
@@ -338,11 +340,13 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *p = cls;
 
-  if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
+  if ( (NULL != p1) &&
+       (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))))
   {
     p1_connected = GNUNET_NO;
   }
-  if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
+  if ( (NULL != p2) &&
+       (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))))
   {
     p2_connected = GNUNET_NO;
   }