From: Bart Polot Date: Sat, 5 Jul 2014 00:13:06 +0000 (+0000) Subject: - document code, small sanity checks X-Git-Tag: initial-import-from-subversion-38251~3499 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=18f42cd3eb6174aab1b07fd05642397e43133bc3;p=oweals%2Fgnunet.git - document code, small sanity checks --- diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index a706aeed3..6b9b07aa6 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -1803,6 +1803,7 @@ GCC_handle_broken (void* cls, return GNUNET_OK; } + t = c->t; fwd = is_fwd (c, id); if (GCC_is_terminal (c, fwd)) { @@ -1811,13 +1812,21 @@ GCC_handle_broken (void* cls, struct CadetPeer *endpoint; int pending_msgs; + if (NULL == t) + { + /* A terminal connection should not have 't' set to NULL. */ + GNUNET_break (0); + return GNUNET_OK; + } neighbor = get_hop (c, !fwd); endpoint = GCP_get_short (c->path->peers[c->path->length - 1]); path_invalidate (c->path); GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2); c->state = CADET_CONNECTION_DESTROYED; - t = c->t; pending_msgs = c->pending_messages; + + /* GCP_connection_pop will destroy the connection when the last message + * is popped! Do not use 'c' after the call. */ while (NULL != (out_msg = GCP_connection_pop (neighbor, c))) { GNUNET_assert (NULL ==