From 3e0deddfaa7544ea3c3dacf197f0f885f7c15a41 Mon Sep 17 00:00:00 2001 From: Banana-J Date: Mon, 5 Feb 2024 21:43:04 +1100 Subject: [PATCH] fix: missing length validaiton after doing regex (#415) Co-authored-by: wjrjerome --- accounts/abi/type.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/accounts/abi/type.go b/accounts/abi/type.go index a1f13ffa29..cec1ce8f56 100644 --- a/accounts/abi/type.go +++ b/accounts/abi/type.go @@ -103,7 +103,11 @@ func NewType(t string) (typ Type, err error) { return typ, err } // parse the type and size of the abi-type. - parsedType := typeRegex.FindAllStringSubmatch(t, -1)[0] + matches := typeRegex.FindAllStringSubmatch(t, -1) + if len(matches) == 0 { + return Type{}, fmt.Errorf("invalid type '%v'", t) + } + parsedType := matches[0] // varSize is the size of the variable var varSize int if len(parsedType[3]) > 0 {