From 53edf5e34cbe0b24fa448770fa07c7580d2bfbff Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 28 Oct 2011 16:41:02 +0000 Subject: [PATCH] Fixed a memory leak --- src/mesh/mesh_tunnel_tree.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c index c58260601..a01ff2ca7 100644 --- a/src/mesh/mesh_tunnel_tree.c +++ b/src/mesh/mesh_tunnel_tree.c @@ -403,14 +403,17 @@ tree_update_first_hops (struct MeshTunnelTree *tree, hop = π GNUNET_PEER_resolve(old->peer, hop); } - copy = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); - *copy = *hop; GNUNET_PEER_resolve(parent->peer, &id); + copy = GNUNET_CONTAINER_multihashmap_get (tree->first_hops, &id.hashPubKey); + if (NULL == copy) + copy = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); + *copy = *hop; + GNUNET_CONTAINER_multihashmap_put( tree->first_hops, &id.hashPubKey, copy, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); + GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); for (n = parent->children_head; NULL != n; n = n->next) { -- 2.25.1