summaryrefslogtreecommitdiff
path: root/src/or/networkstatus.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-10-20 14:40:09 -0400
committerNick Mathewson <nickm@torproject.org>2010-10-20 14:40:09 -0400
commit0ac9a3df6c4ca57dbf5c04ac50d74747451d1494 (patch)
tree24ca689c72f319595ab4066ca55b7d208eca1c46 /src/or/networkstatus.c
parent2849a95691c002108666eb414ff497bf93349e7d (diff)
downloadtor-0ac9a3df6c4ca57dbf5c04ac50d74747451d1494.tar.gz
tor-0ac9a3df6c4ca57dbf5c04ac50d74747451d1494.zip
Fix a logic error in 98aee84. Found by boboper
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r--src/or/networkstatus.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 27049d9ef2..d645ee2b40 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1569,6 +1569,7 @@ networkstatus_set_current_consensus(const char *consensus,
const digests_t *current_digests = NULL;
consensus_waiting_for_certs_t *waiting = NULL;
time_t current_valid_after = 0;
+ int free_consensus = 1; /* Free 'c' at the end of the function */
if (flav < 0) {
/* XXXX we don't handle unrecognized flavors yet. */
@@ -1661,7 +1662,7 @@ networkstatus_set_current_consensus(const char *consensus,
networkstatus_vote_free(waiting->consensus);
tor_free(waiting->body);
waiting->consensus = c;
- c = NULL; /* Prevent free. */
+ free_consensus = 0;
waiting->body = tor_strdup(consensus);
waiting->set_at = now;
waiting->dl_failed = 0;
@@ -1737,7 +1738,7 @@ networkstatus_set_current_consensus(const char *consensus,
if (flav == USABLE_CONSENSUS_FLAVOR) {
current_consensus = c;
- c = NULL; /* Prevent free. */
+ free_consensus = 0; /* Prevent free. */
/* XXXXNM Microdescs: needs a non-ns variant. */
update_consensus_networkstatus_fetch_time(now);
@@ -1780,7 +1781,8 @@ networkstatus_set_current_consensus(const char *consensus,
result = 0;
done:
- networkstatus_vote_free(c);
+ if (free_consensus)
+ networkstatus_vote_free(c);
tor_free(consensus_fname);
tor_free(unverified_fname);
return result;