From 7573f68df3b71d3c5e73b566b405c798cecc7fb7 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 31 Jan 2021 15:35:33 +1100 Subject: [PATCH] Add argument guard for methods --- v2/internal/binding/boundMethod.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/v2/internal/binding/boundMethod.go b/v2/internal/binding/boundMethod.go index 30b72af9..f6ffdb60 100644 --- a/v2/internal/binding/boundMethod.go +++ b/v2/internal/binding/boundMethod.go @@ -30,6 +30,9 @@ func (b *BoundMethod) OutputCount() int { func (b *BoundMethod) ParseArgs(args []json.RawMessage) ([]interface{}, error) { result := make([]interface{}, b.InputCount()) + if len(args) != b.InputCount() { + return nil, fmt.Errorf("received %d arguments to method '%s', expected %d", len(args), b.Name, b.InputCount()) + } for index, arg := range args { typ := b.Inputs[index].reflectType inputValue := reflect.New(typ).Interface()