Skip to content

Commit 3e0dedd

Browse files
fix: missing length validaiton after doing regex (#415)
Co-authored-by: wjrjerome <[email protected]>
1 parent fea90a9 commit 3e0dedd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

accounts/abi/type.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ func NewType(t string) (typ Type, err error) {
103103
return typ, err
104104
}
105105
// parse the type and size of the abi-type.
106-
parsedType := typeRegex.FindAllStringSubmatch(t, -1)[0]
106+
matches := typeRegex.FindAllStringSubmatch(t, -1)
107+
if len(matches) == 0 {
108+
return Type{}, fmt.Errorf("invalid type '%v'", t)
109+
}
110+
parsedType := matches[0]
107111
// varSize is the size of the variable
108112
var varSize int
109113
if len(parsedType[3]) > 0 {

0 commit comments

Comments
 (0)