Added code to avoid creashing on #1904 and identify the origin of the missing path
authorBart Polot <bart@net.in.tum.de>
Thu, 17 Nov 2011 15:46:48 +0000 (15:46 +0000)
committerBart Polot <bart@net.in.tum.de>
Thu, 17 Nov 2011 15:46:48 +0000 (15:46 +0000)
src/mesh/gnunet-service-mesh.c
src/mesh/mesh_tunnel_tree.c

index 786fa474fc6e5052c8604011a1041822bed65701..79096447cedf1f84913126c3530465501c4c7f33 100644 (file)
@@ -3070,18 +3070,25 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
   /* Add paths to peers */
   peer_info = peer_info_get (&msg->peer_id);
   p = tree_get_path_to_peer(t->tree, peer_info->id);
-  for (i = 1; i < p->length && p->peers[i] != myid; i++) /* skip'em */;
-  for (i++; i < p->length; i++)
+  if (NULL != p)
   {
-    struct MeshPeerInfo *aux;
-    struct MeshPeerPath *copy;
+    for (i = 1; i < p->length && p->peers[i] != myid; i++) /* skip'em */;
+    for (i++; i < p->length; i++)
+    {
+      struct MeshPeerInfo *aux;
+      struct MeshPeerPath *copy;
 
-    aux = peer_info_get_short(p->peers[i]);
-    copy = path_duplicate(p);
-    copy->length = i;
-    peer_info_add_path(aux, copy, 0);
+      aux = peer_info_get_short(p->peers[i]);
+      copy = path_duplicate(p);
+      copy->length = i;
+      peer_info_add_path(aux, copy, 0);
+    }
+    path_destroy(p);
+  }
+  else
+  {
+    GNUNET_break (0);
   }
-  path_destroy(p);
 
   /* Message for us? */
   if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity)))
index 2b2e460b51b57aaf6be49d7ddb4e23687e989a32..10d87cc4235bfd73efab182d8bcd789b3a423edd 100644 (file)
@@ -703,7 +703,10 @@ tree_get_path_to_peer (struct MeshTunnelTree *t, GNUNET_PEER_Id peer)
 
   n = tree_find_peer (t, peer);
   if (NULL == n)
+  {
+    GNUNET_break (0);
     return NULL;
+  }
   p = path_new (0);
 
   /* Building the path (inverted!) */
@@ -714,6 +717,7 @@ tree_get_path_to_peer (struct MeshTunnelTree *t, GNUNET_PEER_Id peer)
     n = n->parent;
     if (NULL == n)
     {
+      GNUNET_break (0);
       path_destroy (p);
       return NULL;
     }