Skip to content

Commit 45ee298

Browse files
committed
Check env.UseGas return value
1 parent 5ca19fb commit 45ee298

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libevm/legacy/legacy.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ func (c PrecompiledStatefulContract) Upgrade() vm.PrecompiledStatefulContract {
4444
return nil, fmt.Errorf("%w: %d > %d", errRemainingGasExceedsSuppliedGas, remainingGas, gas)
4545
}
4646
if used := gas - remainingGas; used > 0 {
47-
env.UseGas(used)
47+
if hasEnoughGas := env.UseGas(used); !hasEnoughGas {
48+
return nil, vm.ErrOutOfGas
49+
}
4850
}
4951
return ret, err
5052
}

0 commit comments

Comments
 (0)