Compare CALL gas value against gas remaining

This commit is contained in:
nicksavers 2014-08-24 12:13:04 +02:00
parent 7454d99b60
commit 1f3935a3ae
1 changed files with 3 additions and 2 deletions

View File

@ -140,8 +140,9 @@ public class VM {
break; break;
case CALL: case CALL:
program.spendGas(GasCost.CALL, op.name()); program.spendGas(GasCost.CALL, op.name());
if(stack.get(stack.size()-1).value().compareTo(MAX_GAS) == 1) { BigInteger callGas = stack.get(stack.size()-1).value();
throw program.new OutOfGasException(); // protect against overflow (needs refactoring) if(callGas.compareTo(program.getGas().value()) == 1) {
throw program.new OutOfGasException();
} }
BigInteger x = stack.get(stack.size()-6).value().add(stack.get(stack.size()-7).value()); BigInteger x = stack.get(stack.size()-6).value().add(stack.get(stack.size()-7).value());
BigInteger y = stack.get(stack.size()-4).value().add(stack.get(stack.size()-5).value()); BigInteger y = stack.get(stack.size()-4).value().add(stack.get(stack.size()-5).value());