Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-from-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Nov 6, 2023
2 parents f183238 + e19b3c6 commit d1bb152
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion executor/executorMemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ func MemLoadFromMemory(memory Memory, memPtr MemPtr, length MemLength) ([]byte,
return nil, fmt.Errorf("mem load: %w", ErrMemoryNegativeLength)
}

result := make([]byte, length)
var result []byte
if isRequestedEndTooLarge {
result = make([]byte, memoryLength-uint32(memPtr))
copy(result, memoryView[memPtr:])
} else {
result = make([]byte, requestedEnd-memPtr)
copy(result, memoryView[memPtr:requestedEnd])
}

Expand Down
2 changes: 1 addition & 1 deletion vmhost/contexts/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func TestRuntimeContext_MemLoadCases(t *testing.T) {
length = 9
memContents, err = memLoad(runtimeCtx, offset, length)
require.Nil(t, err)
require.Equal(t, []byte{'e', 's', 't', ' ', 'd', 'a', 't', 'a', 0}, memContents)
require.Equal(t, []byte{'e', 's', 't', ' ', 'd', 'a', 't', 'a'}, memContents)

// Zero length
offset = int32(runtimeCtx.iTracker.instance.MemLength() - 8)
Expand Down

0 comments on commit d1bb152

Please sign in to comment.