vm: don't allocate another stack for entry scripts

vm.New() creates a new stack, then we load an entry script with
LoadScriptWithFlags and it creates another one which doesn't make much
sense. rvcount is -1 for it, so all elements are to be copied down anyway and
it's clear so a new loaded script can't dig down to anything it shouldn't be
able to.
This commit is contained in:
Roman Khimov 2021-12-02 15:59:51 +03:00
parent ac7e922606
commit 53cfde62de

View file

@ -317,7 +317,9 @@ func (v *VM) loadScriptWithCallingHash(b []byte, exe *nef.File, caller util.Uint
v.checkInvocationStackSize()
ctx := NewContextWithParams(b, rvcount, offset)
if rvcount != -1 || v.estack.Len() != 0 {
v.estack = newStack("evaluation", &v.refs)
}
ctx.estack = v.estack
initStack(&ctx.tryStack, "exception", nil)
ctx.callFlag = f