Skip to content

Commit

Permalink
rb
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKorcz committed Feb 14, 2022
1 parent f647976 commit 674cc7c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/storage/wal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package wal

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -214,10 +213,12 @@ func visitEnumNumber(enum protoreflect.EnumDescriptor, number protoreflect.EnumN
if err != nil {
return err
}
if int(number) >= enum.Values().Len() || int(number) < 0 {
return errors.New("could not visit EnumNumber")
intNumber := int(number)
fields := enum.Values()
if intNumber >= fields.Len() || intNumber < 0 {
return fmt.Errorf("could not visit EnumNumber [%d]", intNumber)
}
return visitEnumValue(enum.Values().Get(int(number)), visitor)
return visitEnumValue(fields.Get(intNumber), visitor)
}

func visitEnumValue(enum protoreflect.EnumValueDescriptor, visitor Visitor) error {
Expand Down

0 comments on commit 674cc7c

Please sign in to comment.