Skip to content

Commit

Permalink
laudiacay/actors review f23 (#1325)
Browse files Browse the repository at this point in the history
* overflow protection in charge_gas

* fixing overflow protection to be like in lotus

* linters
  • Loading branch information
laudiacay authored Dec 14, 2021
1 parent 35aa3d5 commit e4c07d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vm/interpreter/src/gas_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ impl GasTracker {
/// enough gas remaining for charge.
pub fn charge_gas(&mut self, charge: GasCharge) -> Result<(), ActorError> {
let to_use = charge.total();
let used = self.gas_used + to_use;
if used > self.gas_available {

if self.gas_used > self.gas_available - to_use {
self.gas_used = self.gas_available;
Err(actor_error!(SysErrOutOfGas;
"not enough gas (used={}) (available={})",
used, self.gas_available
to_use, self.gas_available
))
} else {
self.gas_used += to_use;
Expand Down

0 comments on commit e4c07d1

Please sign in to comment.