diff --git a/go.mod b/go.mod index abe66aa8..dceea82c 100644 --- a/go.mod +++ b/go.mod @@ -7,10 +7,10 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 github.com/gin-gonic/gin v1.9.1 github.com/mitchellh/mapstructure v1.5.0 - github.com/multiversx/mx-chain-core-go v1.2.17 + github.com/multiversx/mx-chain-core-go v1.2.19-0.20231123115253-158315dc4238 github.com/multiversx/mx-chain-crypto-go v1.2.8 github.com/multiversx/mx-chain-logger-go v1.0.13 - github.com/multiversx/mx-chain-vm-common-go v1.5.6 + github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231123115741-c8a4816c447a github.com/multiversx/mx-components-big-int v1.0.0 github.com/pelletier/go-toml v1.9.3 github.com/stretchr/testify v1.8.3 diff --git a/go.sum b/go.sum index b77094dd..66e6d090 100644 --- a/go.sum +++ b/go.sum @@ -67,14 +67,14 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiversx/mx-chain-core-go v1.2.17 h1:/7YEuowxnpOtZLAJbuibNWE/8rDcG+WMhNVvrnljPg0= -github.com/multiversx/mx-chain-core-go v1.2.17/go.mod h1:BILOGHUOIG5dNNX8cgkzCNfDaVtoYrJRYcPnpxRMH84= +github.com/multiversx/mx-chain-core-go v1.2.19-0.20231123115253-158315dc4238 h1:nlDelmQou2635GW2YACZMAHTc+cRxBvtHE0dRQuVC0U= +github.com/multiversx/mx-chain-core-go v1.2.19-0.20231123115253-158315dc4238/go.mod h1:BILOGHUOIG5dNNX8cgkzCNfDaVtoYrJRYcPnpxRMH84= github.com/multiversx/mx-chain-crypto-go v1.2.8 h1:wOgVlUaO5X4L8iEbFjcQcL8SZvv6WZ7LqH73BiRPhxU= github.com/multiversx/mx-chain-crypto-go v1.2.8/go.mod h1:fkaWKp1rbQN9wPKya5jeoRyC+c/SyN/NfggreyeBw+8= github.com/multiversx/mx-chain-logger-go v1.0.13 h1:eru/TETo0MkO4ZTnXsQDKf4PBRpAXmqjT02klNT/JnY= github.com/multiversx/mx-chain-logger-go v1.0.13/go.mod h1:MZJhTAtZTJxT+yK2EHc4ZW3YOHUc1UdjCD0iahRNBZk= -github.com/multiversx/mx-chain-vm-common-go v1.5.6 h1:hAWCIkFc5vcweBzpataVsJf0PCPc7tfQBGW/q8nzQ8A= -github.com/multiversx/mx-chain-vm-common-go v1.5.6/go.mod h1:S8bbBlbOVKgl8YBnlmmHakYiSXjKPcSd6WW+Nku/Xys= +github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231123115741-c8a4816c447a h1:LYEKM1wKOiT3SKqYIJEUDVZEV7VM5ISVjXkg1Jbxsk0= +github.com/multiversx/mx-chain-vm-common-go v1.5.9-0.20231123115741-c8a4816c447a/go.mod h1:Uu29N9DDx6iWDrDVPRUiLosrzlbNsYgpNfyhOQztEfE= github.com/multiversx/mx-components-big-int v1.0.0 h1:Wkr8lSzK2nDqixOrrBa47VNuqdhV1m/aJhaP1EMaiS8= github.com/multiversx/mx-components-big-int v1.0.0/go.mod h1:maIEMgHlNE2u78JaDD0oLzri+ShgU4okHfzP3LWGdQM= github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= diff --git a/vmhost/contexts/runtime.go b/vmhost/contexts/runtime.go index 66c14ab3..27800f79 100644 --- a/vmhost/contexts/runtime.go +++ b/vmhost/contexts/runtime.go @@ -1084,10 +1084,13 @@ func (context *runtimeContext) MemLoad(offset int32, length int32) ([]byte, erro return nil, fmt.Errorf("mem load: %w", vmhost.ErrNegativeLength) } - result := make([]byte, length) + var result []byte + if isRequestedEndTooLarge { + result = make([]byte, memoryLength-uint32(offset)) copy(result, memoryView[offset:]) } else { + result = make([]byte, requestedEnd-offset) copy(result, memoryView[offset:requestedEnd]) } diff --git a/vmhost/contexts/runtime_test.go b/vmhost/contexts/runtime_test.go index 419f9a9c..f29490c3 100644 --- a/vmhost/contexts/runtime_test.go +++ b/vmhost/contexts/runtime_test.go @@ -652,7 +652,7 @@ func TestRuntimeContext_MemLoadCases(t *testing.T) { length = 9 memContents, err = runtimeContext.MemLoad(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(memory.Length() - 8)