From a885f84cad0e8a8ee6a20126a2fe28f82e561023 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Mon, 25 Oct 2021 10:51:50 +0300 Subject: [PATCH] compiler: fail if some functions are missing Signed-off-by: Evgeniy Stratonikov --- pkg/compiler/codegen.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index 1fefc5e51..4eebd5c9d 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -2168,6 +2168,9 @@ func (c *codegen) replaceLabelWithOffset(ip int, arg []byte) (int, error) { if int(index) > len(c.l) { return 0, fmt.Errorf("unexpected label number: %d (max %d)", index, len(c.l)) } + if c.l[index] < 0 { + return 0, fmt.Errorf("invalid label target: %d at %d", c.l[index], ip) + } offset := c.l[index] - ip if offset > math.MaxInt32 || offset < math.MinInt32 { return 0, fmt.Errorf("label offset is too big at the instruction %d: %d (max %d, min %d)",