summaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-09-11 00:11:26 -0400
committerNick Mathewson <nickm@torproject.org>2014-09-11 00:11:26 -0400
commit48558ed1aa070ef121b339eef88e7822f8e45978 (patch)
treed757235e3645d73e1ca0026afa4f8c6058ad0917 /src/or/routerlist.c
parent73ee161d8a7bc06eefa58654cbfe421449921eec (diff)
parent2491eadf002e993bee11aa76597ec7f361d8f6e5 (diff)
downloadtor-48558ed1aa070ef121b339eef88e7822f8e45978.tar.gz
tor-48558ed1aa070ef121b339eef88e7822f8e45978.zip
Merge remote-tracking branch 'public/bug13104_025'
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index a018181026..1faa05f06f 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1804,7 +1804,7 @@ scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries,
uint64_t *total_out)
{
double total = 0.0;
- double scale_factor;
+ double scale_factor = 0.0;
int i;
/* big, but far away from overflowing an int64_t */
#define SCALE_TO_U64_MAX ((int64_t) (INT64_MAX / 4))
@@ -1812,7 +1812,8 @@ scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries,
for (i = 0; i < n_entries; ++i)
total += entries[i].dbl;
- scale_factor = SCALE_TO_U64_MAX / total;
+ if (total > 0.0)
+ scale_factor = SCALE_TO_U64_MAX / total;
for (i = 0; i < n_entries; ++i)
entries[i].u64 = tor_llround(entries[i].dbl * scale_factor);