From 705c7f106fd745f356eb4060905905e32084875d Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 3 Oct 2019 16:02:15 +0300 Subject: [PATCH] vm: don't panic if there is no result in PopResult() This function is intended to be ran outside of the execute's panic recovery mechanism, so it shouldn't panic if there is no result. --- pkg/vm/vm.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index a12516ee3..cb3448570 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -187,7 +187,11 @@ func (v *VM) Context() *Context { // PopResult is used to pop the first item of the evaluation stack. This allows // us to test compiler and vm in a bi-directional way. func (v *VM) PopResult() interface{} { - return v.estack.Pop().value.Value() + e := v.estack.Pop() + if e != nil { + return e.Value() + } + return nil } // Stack returns json formatted representation of the given stack.