diff --git a/crates/precompile/src/modexp.rs b/crates/precompile/src/modexp.rs index 4344f5cce9..6d47c8d53b 100644 --- a/crates/precompile/src/modexp.rs +++ b/crates/precompile/src/modexp.rs @@ -81,6 +81,9 @@ where } let (r, gas_cost) = if base_len == 0 && mod_len == 0 { + if min_gas > gas_limit { + return Err(Error::OutOfGas); + } (BigUint::zero(), min_gas) } else { // set limit for exp overflow