[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r16830: {tor} Fix some apparent leaks in voting. If authorities suddenly s (tor/trunk/src/or)
Author: nickm
Date: 2008-09-10 01:33:49 -0400 (Wed, 10 Sep 2008)
New Revision: 16830
Modified:
tor/trunk/src/or/dirvote.c
Log:
Fix some apparent leaks in voting. If authorities suddenly start segfaulting, this could be a patch to look harder at.
Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c 2008-09-10 04:07:16 UTC (rev 16829)
+++ tor/trunk/src/or/dirvote.c 2008-09-10 05:33:49 UTC (rev 16830)
@@ -528,8 +528,7 @@
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 @@
}
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 @@
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 @@
/* 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 @@
smartlist_free(chosen_flags);
smartlist_free(versions);
smartlist_free(exitsummaries);
+ tor_free(bandwidths);
}
/* Add a signature. */
@@ -1134,6 +1134,7 @@
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);