From 04aa7159a32b3c375366e7884475442a25719149 Mon Sep 17 00:00:00 2001 From: luxq Date: Wed, 6 Jul 2022 15:12:39 +0800 Subject: [PATCH] merge #23381 --- core/vm/instructions.go | 4 ++++ core/vm/interpreter.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index adf44b7f481f9..ed4a087f439ba 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -701,6 +701,7 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]by } stack.push(&temp) if err == nil || err == ErrExecutionReverted { + ret = common.CopyBytes(ret) callContext.memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } callContext.contract.Gas += returnGas @@ -735,6 +736,7 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ( } stack.push(&temp) if err == nil || err == ErrExecutionReverted { + ret = common.CopyBytes(ret) callContext.memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } callContext.contract.Gas += returnGas @@ -762,6 +764,7 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, callContext *callCt } stack.push(&temp) if err == nil || err == ErrExecutionReverted { + ret = common.CopyBytes(ret) callContext.memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } callContext.contract.Gas += returnGas @@ -789,6 +792,7 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) } stack.push(&temp) if err == nil || err == ErrExecutionReverted { + ret = common.CopyBytes(ret) callContext.memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) } callContext.contract.Gas += returnGas diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 1e2a661debd1d..cc8a1daafe2cc 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -288,7 +288,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // if the operation clears the return data (e.g. it has returning data) // set the last return to the result of the operation. if operation.returns { - in.returnData = common.CopyBytes(res) + in.returnData = res } switch {