From 57c2b8f499605815aad123549db8edb8566fa370 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Wed, 28 Jan 2015 19:23:04 +0000 Subject: - fixes for NPE --- src/rps/gnunet-service-rps.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 2762339ae..4f4214248 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c @@ -1389,7 +1389,8 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) { struct PeerContext *peer_ctx; const struct GNUNET_CADET_Channel *ch = (const struct GNUNET_CADET_Channel *) cls; - struct GNUNET_CADET_Channel *destroy; + struct GNUNET_CADET_Channel *recv; + struct GNUNET_CADET_Channel *send; peer_ctx = (struct PeerContext *) value; @@ -1402,25 +1403,27 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) peer_ctx->is_live_task = NULL; } - if (NULL != peer_ctx->send_channel - && ch != peer_ctx->send_channel) + send = peer_ctx->send_channel; + peer_ctx->send_channel = NULL; + recv = peer_ctx->send_channel; + peer_ctx->recv_channel = NULL; + + if (NULL != send + && ch != send) { - destroy = peer_ctx->send_channel; - peer_ctx->send_channel = NULL; - GNUNET_CADET_channel_destroy (destroy); + GNUNET_CADET_channel_destroy (send); } - if (NULL != peer_ctx->recv_channel - && ch != peer_ctx->recv_channel) + if (NULL != recv + && ch != recv) { - destroy = peer_ctx->recv_channel; - peer_ctx->recv_channel = NULL; - GNUNET_CADET_channel_destroy (destroy); + GNUNET_CADET_channel_destroy (recv); } if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); + /* FIXME this will be called twice until the fixme in line 1451 is fixed */ GNUNET_free (peer_ctx); return GNUNET_YES; } -- cgit v1.2.3