Skip to content

Commit

Permalink
fix: integer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
samlior committed Dec 16, 2020
1 parent 4afe77d commit dc3d967
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
if(reward_total_weight != 0 ){
for(const witness_object& wit : wits){
if(!wit.is_banned && wit.is_valid){
share_type reward_pay = staking_awards_pools_bak * wit.total_vote_weights / reward_total_weight;
auto int128_reward_pay = static_cast<int128_t>(staking_awards_pools_bak.value) * static_cast<int128_t>(wit.total_vote_weights.value) / static_cast<int128_t>(reward_total_weight.value);
share_type reward_pay = static_cast<int64_t>(int128_reward_pay);
reward_pay = std::min(reward_pay, dpo.current_staking_reward_pool);
modify( dpo, [&]( dynamic_global_property_object& _dpo )
{
Expand Down

0 comments on commit dc3d967

Please sign in to comment.