Additional check before conversion
This commit is contained in:
parent
aca68dcfe7
commit
c8d94c981b
@ -491,8 +491,12 @@ impl Interpreter {
|
|||||||
// s * memory_gas + s * s / quad_coeff_div
|
// s * memory_gas + s * s / quad_coeff_div
|
||||||
let a = overflowing!(s.overflowing_mul(U256::from(schedule.memory_gas)));
|
let a = overflowing!(s.overflowing_mul(U256::from(schedule.memory_gas)));
|
||||||
// We need to go to U512 to calculate s*s/quad_coeff_div
|
// We need to go to U512 to calculate s*s/quad_coeff_div
|
||||||
let b = U256::from(U512::from(s) * U512::from(s) / U512::from(schedule.quad_coeff_div));
|
let b = U512::from(s) * U512::from(s) / U512::from(schedule.quad_coeff_div);
|
||||||
Ok(overflowing!(a.overflowing_add(b)))
|
if b > U512::from(!U256::zero()) {
|
||||||
|
Err(evm::Error::OutOfGas)
|
||||||
|
} else {
|
||||||
|
Ok(overflowing!(a.overflowing_add(U256::from(b))))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let current_mem_size = U256::from(current_mem_size);
|
let current_mem_size = U256::from(current_mem_size);
|
||||||
let req_mem_size_rounded = (overflowing!(mem_size.overflowing_add(U256::from(31))) >> 5) << 5;
|
let req_mem_size_rounded = (overflowing!(mem_size.overflowing_add(U256::from(31))) >> 5) << 5;
|
||||||
|
Loading…
Reference in New Issue
Block a user