From: Nathan S. Evans Date: Sat, 20 Nov 2010 17:55:45 +0000 (+0000) Subject: only free when necessary (double free bug) X-Git-Tag: initial-import-from-subversion-38251~19667 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=04a52fec55d934e5a863cc9e860db9387f78a3b5;p=oweals%2Fgnunet.git only free when necessary (double free bug) --- diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index cd0c143a0..00fa62398 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -2115,7 +2115,10 @@ static int route_result_message(struct GNUNET_MessageHeader *msg, pos = pos->next; } if (msg_ctx->bloom != NULL) + { GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); + msg_ctx->bloom = NULL; + } return 0; } @@ -3458,7 +3461,10 @@ route_message(const struct GNUNET_MessageHeader *msg, } #endif if (msg_ctx->bloom != NULL) + { GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); + msg_ctx->bloom = NULL; + } return; } @@ -3506,7 +3512,6 @@ route_message(const struct GNUNET_MessageHeader *msg, } #endif - GNUNET_CONTAINER_bloomfilter_add (msg_ctx->bloom, &my_identity.hashPubKey); hash_from_uid (msg_ctx->unique_id, &unique_hash); if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (recent.hashmap, &unique_hash)) @@ -3581,6 +3586,7 @@ route_message(const struct GNUNET_MessageHeader *msg, { GNUNET_CONTAINER_bloomfilter_or2(recent_req->bloom, msg_ctx->bloom, DHT_BLOOM_SIZE); GNUNET_CONTAINER_bloomfilter_free(msg_ctx->bloom); + msg_ctx->bloom = NULL; } } @@ -4270,7 +4276,11 @@ handle_dht_p2p_route_request (void *cls, msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE; msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; demultiplex_message(enc_msg, msg_ctx); - GNUNET_CONTAINER_bloomfilter_free (msg_ctx->bloom); + if (msg_ctx->bloom != NULL) + { + GNUNET_CONTAINER_bloomfilter_free (msg_ctx->bloom); + msg_ctx->bloom = NULL; + } GNUNET_free(msg_ctx); return GNUNET_YES; }