Skip to content

Commit

Permalink
pfrd: fix mod by zero error when all branches are filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Jun 25, 2021
1 parent bcd5fde commit c06db9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/policy_eppfrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ namespace eppfrd
uint64_t idx;
uint64_t threshold;

if(sum_ == 0)
return NULL;

idx = 0;
threshold = RND::rand64(sum_);
for(size_t i = 0; i < branchinfo_.size(); i++)
Expand Down
3 changes: 3 additions & 0 deletions src/policy_msppfrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ namespace msppfrd
uint64_t idx;
uint64_t threshold;

if(sum_ == 0)
return NULL;

idx = 0;
threshold = RND::rand64(sum_);
for(size_t i = 0; i < branchinfo_.size(); i++)
Expand Down
3 changes: 3 additions & 0 deletions src/policy_pfrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ namespace pfrd
uint64_t idx;
uint64_t threshold;

if(sum_ == 0)
return NULL;

idx = 0;
threshold = RND::rand64(sum_);
for(size_t i = 0; i < branchinfo_.size(); i++)
Expand Down

0 comments on commit c06db9c

Please sign in to comment.