summaryrefslogtreecommitdiff
path: root/src/or/dirvote.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-09-10 05:33:49 +0000
committerNick Mathewson <nickm@torproject.org>2008-09-10 05:33:49 +0000
commit45205126fe72cf09c45f88460e9e4c1888ada9b6 (patch)
tree53ae7b03d37bde3f83fe62db9656438362070454 /src/or/dirvote.c
parentaa69d586ead70edd87d66f5d6927a170edd5e90d (diff)
downloadtor-45205126fe72cf09c45f88460e9e4c1888ada9b6.tar.gz
tor-45205126fe72cf09c45f88460e9e4c1888ada9b6.zip
Fix some apparent leaks in voting. If authorities suddenly start segfaulting, this could be a patch to look harder at.
svn:r16830
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r--src/or/dirvote.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index c036576fb8..2076875c46 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -528,8 +528,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_t *combined_client_versions = smartlist_create();
smartlist_t *combined_server_versions = smartlist_create();
- SMARTLIST_FOREACH(votes, networkstatus_t *, v,
- {
+ SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
tor_assert(v->type == NS_TYPE_VOTE);
va_times[v_sl_idx] = v->valid_after;
fu_times[v_sl_idx] = v->fresh_until;
@@ -556,7 +555,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
SMARTLIST_FOREACH(v->known_flags, const char *, cp,
smartlist_add(flags, tor_strdup(cp)));
- });
+ } SMARTLIST_FOREACH_END(v);
valid_after = median_time(va_times, n_votes);
fresh_until = median_time(fu_times, n_votes);
valid_until = median_time(vu_times, n_votes);
@@ -835,7 +834,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
num_bandwidths = 0;
/* Okay, go through all the entries for this digest. */
- SMARTLIST_FOREACH(votes, networkstatus_t *, v, {
+ SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
if (index[v_sl_idx] >= size[v_sl_idx])
continue; /* out of entries. */
rs = smartlist_get(v->routerstatus_list, index[v_sl_idx]);
@@ -868,7 +867,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* count bandwidths */
if (rs->status.has_bandwidth)
bandwidths[num_bandwidths++] = rs->status.bandwidth;
- });
+ } SMARTLIST_FOREACH_END(v);
/* We don't include this router at all unless more than half of
* the authorities we believe in list it. */
@@ -1084,6 +1083,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_free(chosen_flags);
smartlist_free(versions);
smartlist_free(exitsummaries);
+ tor_free(bandwidths);
}
/* Add a signature. */
@@ -1134,6 +1134,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
tor_free(client_versions);
tor_free(server_versions);
+ SMARTLIST_FOREACH(flags, char *, cp, tor_free(cp));
smartlist_free(flags);
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
smartlist_free(chunks);