From: Bart Polot Date: Thu, 17 Nov 2011 15:46:48 +0000 (+0000) Subject: Added code to avoid creashing on #1904 and identify the origin of the missing path X-Git-Tag: initial-import-from-subversion-38251~15888 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=875bd1aaf60122eeef188916c728b23ca86a9d83;p=oweals%2Fgnunet.git Added code to avoid creashing on #1904 and identify the origin of the missing path --- diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 786fa474f..79096447c 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -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))) diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c index 2b2e460b5..10d87cc42 100644 --- a/src/mesh/mesh_tunnel_tree.c +++ b/src/mesh/mesh_tunnel_tree.c @@ -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; }