summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2017-11-08 14:17:37 +1100
committerNick Mathewson <nickm@torproject.org>2017-11-08 10:45:18 -0500
commit4f944cc4cc1971baf2924bc3f713feef7b010691 (patch)
tree6da729e441ff3b5f84fe50549738188de5a373fc
parentfcaa4ab82463a0a27a0605d5aa01ed7d01e3387a (diff)
downloadtor-4f944cc4cc1971baf2924bc3f713feef7b010691.tar.gz
tor-4f944cc4cc1971baf2924bc3f713feef7b010691.zip
Check arguments and initialise variables in compute_weighted_bandwidths()
Cleanup after 23318.
-rw-r--r--src/or/routerlist.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 80486cccbc..c9d2cbaeaf 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2547,9 +2547,12 @@ compute_weighted_bandwidths(const smartlist_t *sl,
double Wg = -1, Wm = -1, We = -1, Wd = -1;
double Wgb = -1, Wmb = -1, Web = -1, Wdb = -1;
guardfraction_bandwidth_t guardfraction_bw;
- double *bandwidths;
+ double *bandwidths = NULL;
double total_bandwidth = 0.0;
+ tor_assert(sl);
+ tor_assert(bandwidths_out);
+
/* Can't choose exit and guard at same time */
tor_assert(rule == NO_WEIGHTING ||
rule == WEIGHT_FOR_EXIT ||
@@ -2557,6 +2560,8 @@ compute_weighted_bandwidths(const smartlist_t *sl,
rule == WEIGHT_FOR_MID ||
rule == WEIGHT_FOR_DIR);
+ *bandwidths_out = NULL;
+
if (total_bandwidth_out) {
*total_bandwidth_out = 0.0;
}