Skip to content

Commit

Permalink
Additional bounds checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Jul 30, 2024
1 parent 6b10e40 commit ee5692d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ func (d *Fork) UnmarshalJSON(input []byte) error {

// String returns a string representation of the item.
func (d Fork) String() string {
if int(d) < 0 || int(d) >= len(forkStrings) {
return "unknown"
}

return forkStrings[d]
}
4 changes: 4 additions & 0 deletions spec/transactiontype.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@ func (d *TransactionType) UnmarshalJSON(input []byte) error {

// String returns a string representation of the item.
func (d TransactionType) String() string {
if int(d) < 0 || int(d) >= len(transactionTypeStrings) {
return "unknown"
}

return transactionTypeStrings[d]
}

0 comments on commit ee5692d

Please sign in to comment.