From fd87cd4c54946521cacc28e37addfd50ce821f9c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 25 Aug 2021 11:20:43 +0300 Subject: [PATCH] vm: fix (*Stack).Clear to clean up references --- pkg/vm/stack.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/vm/stack.go b/pkg/vm/stack.go index 8a300628a..f94023f34 100644 --- a/pkg/vm/stack.go +++ b/pkg/vm/stack.go @@ -141,6 +141,9 @@ func initStack(s *Stack, n string, refc *refCounter) { // Clear clears all elements on the stack and set its length to 0. func (s *Stack) Clear() { if s.elems != nil { + for _, el := range s.elems { + s.refs.Remove(el.value) + } s.elems = s.elems[:0] } }