Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix possible overflow in fn refund
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Apr 22, 2020
1 parent 64f4c4f commit 25139f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion frame/contracts/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<T: Trait> GasMeter<T> {
// This can be used after dispatching a runtime call to refund gas that was not
// used by the dispatchable.
pub fn refund(&mut self, gas: Gas) {
self.gas_left = (self.gas_left + gas).max(self.gas_limit);
self.gas_left = self.gas_left.saturating_add(gas).max(self.gas_limit);
}

/// Allocate some amount of gas and perform some work with
Expand Down

0 comments on commit 25139f8

Please sign in to comment.