fixed issues found by go-fuzz
This commit is contained in:
parent
1674abae73
commit
15d372ac55
3 changed files with 37 additions and 9 deletions
25
helper.go
25
helper.go
|
|
@ -12,6 +12,15 @@ const (
|
|||
anys = string(any)
|
||||
)
|
||||
|
||||
func checkFields(s []string, val string) error {
|
||||
for _, v := range s {
|
||||
if v == "" {
|
||||
return errors.New("invalid subfield: " + val)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type less func(i, j int) bool
|
||||
|
||||
func reverse(f less) less {
|
||||
|
|
@ -20,12 +29,18 @@ func reverse(f less) less {
|
|||
}
|
||||
}
|
||||
|
||||
func index(f Filter, i int, fields []string) (val reflect.Value) {
|
||||
val = reflect.ValueOf(f.Index(i)).FieldByName(fields[0])
|
||||
for j := 1; j < len(fields); j++ {
|
||||
val = val.FieldByName(fields[j])
|
||||
func walkFields(v reflect.Value, fields []string) reflect.Value {
|
||||
for i := 0; i < len(fields); i++ {
|
||||
if v.Kind() != reflect.Struct {
|
||||
return reflect.ValueOf(nil)
|
||||
}
|
||||
v = v.FieldByName(fields[i])
|
||||
}
|
||||
return
|
||||
return v
|
||||
}
|
||||
|
||||
func index(f Filter, i int, fields []string) (val reflect.Value) {
|
||||
return walkFields(reflect.ValueOf(f.Index(i)).FieldByName(fields[0]), fields[1:])
|
||||
}
|
||||
|
||||
func makeLess(f Filter, fields []string) less {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue