From a203c3a1c6c945437162dcf655bf49307065b8c2 Mon Sep 17 00:00:00 2001 From: nicksavers Date: Sun, 24 Aug 2014 14:28:15 +0200 Subject: [PATCH] Workaround overflow bug in poc5 --- ethereumj-core/src/main/java/org/ethereum/vm/VM.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java index a8c65597..55b02226 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java @@ -144,9 +144,10 @@ public class VM { 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 y = stack.get(stack.size()-4).value().add(stack.get(stack.size()-5).value()); - newMemSize = x.max(y); + // Casting to long (causing overflow) as workaround for PoC5 - should be removed for PoC6 + long x = stack.get(stack.size()-6).value().add(stack.get(stack.size()-7).value()).longValue(); + long y = stack.get(stack.size()-4).value().add(stack.get(stack.size()-5).value()).longValue(); + newMemSize = BigInteger.valueOf(Math.max(x, y)); break; case CREATE: program.spendGas(GasCost.CREATE, op.name());