fix: missing length validaiton after doing regex (#415)

Co-authored-by: wjrjerome <wjrjerome@babylonchain.io>
This commit is contained in:
Banana-J 2024-02-05 21:43:04 +11:00 committed by GitHub
parent fea90a97df
commit 3e0deddfaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {