vm: fix OOM during nested structure cloning
Resulting item can't have more than MaxStackSize elements. Technically this limits to MaxStackSize cloned elements but it's considered to be enough to mitigate the issue (the next size check is going to happen during push to the stack). See neo-project/neo#2534, thanks @vang1ong7ang.
This commit is contained in:
parent
1853d0c713
commit
cfe41abd35
4 changed files with 59 additions and 9 deletions
|
@ -465,6 +465,15 @@ func TestNewVeryBigInteger(t *testing.T) {
|
|||
check(false, new(big.Int).Mul(maxBitSet, big.NewInt(2)))
|
||||
}
|
||||
|
||||
func TestStructClone(t *testing.T) {
|
||||
st0 := Struct{}
|
||||
st := Struct{value: []Item{&st0}}
|
||||
_, err := st.Clone(1)
|
||||
require.NoError(t, err)
|
||||
_, err = st.Clone(0)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestDeepCopy(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue