From 8cba62cc2afc661f75b519f0b4ddf7c8892f15a0 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 2 Jan 2010 13:13:30 -0500 Subject: don't div by 0 during path selection --- src/or/routerlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/or/routerlist.c') diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 029bd9a0c1..72b890b9fd 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1698,12 +1698,12 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, * For detailed derivation of this formula, see * http://archives.seul.org/or/dev/Jul-2007/msg00056.html */ - if (rule == WEIGHT_FOR_EXIT) + if (rule == WEIGHT_FOR_EXIT || !total_exit_bw) exit_weight = 1.0; else exit_weight = 1.0 - all_bw/(3.0*exit_bw); - if (rule == WEIGHT_FOR_GUARD) + if (rule == WEIGHT_FOR_GUARD || !total_guard_bw) guard_weight = 1.0; else guard_weight = 1.0 - all_bw/(3.0*guard_bw); -- cgit v1.2.3-54-g00ecf