Merge pull request #1049 from saschagrunert/segfault
Fix possible panics in slice type assertion
This commit is contained in:
commit
b226f3befd
@ -155,11 +155,9 @@ func (c *Context) Float64Slice(name string) []float64 {
|
|||||||
func lookupFloat64Slice(name string, set *flag.FlagSet) []float64 {
|
func lookupFloat64Slice(name string, set *flag.FlagSet) []float64 {
|
||||||
f := set.Lookup(name)
|
f := set.Lookup(name)
|
||||||
if f != nil {
|
if f != nil {
|
||||||
parsed, err := (f.Value.(*Float64Slice)).Value(), error(nil)
|
if slice, ok := f.Value.(*Float64Slice); ok {
|
||||||
if err != nil {
|
return slice.Value()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return parsed
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -151,11 +151,9 @@ func (c *Context) Int64Slice(name string) []int64 {
|
|||||||
func lookupInt64Slice(name string, set *flag.FlagSet) []int64 {
|
func lookupInt64Slice(name string, set *flag.FlagSet) []int64 {
|
||||||
f := set.Lookup(name)
|
f := set.Lookup(name)
|
||||||
if f != nil {
|
if f != nil {
|
||||||
parsed, err := (f.Value.(*Int64Slice)).Value(), error(nil)
|
if slice, ok := f.Value.(*Int64Slice); ok {
|
||||||
if err != nil {
|
return slice.Value()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return parsed
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -165,11 +165,9 @@ func (c *Context) IntSlice(name string) []int {
|
|||||||
func lookupIntSlice(name string, set *flag.FlagSet) []int {
|
func lookupIntSlice(name string, set *flag.FlagSet) []int {
|
||||||
f := set.Lookup(name)
|
f := set.Lookup(name)
|
||||||
if f != nil {
|
if f != nil {
|
||||||
parsed, err := (f.Value.(*IntSlice)).Value(), error(nil)
|
if slice, ok := f.Value.(*IntSlice); ok {
|
||||||
if err != nil {
|
return slice.Value()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return parsed
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -149,11 +149,9 @@ func (c *Context) StringSlice(name string) []string {
|
|||||||
func lookupStringSlice(name string, set *flag.FlagSet) []string {
|
func lookupStringSlice(name string, set *flag.FlagSet) []string {
|
||||||
f := set.Lookup(name)
|
f := set.Lookup(name)
|
||||||
if f != nil {
|
if f != nil {
|
||||||
parsed, err := (f.Value.(*StringSlice)).Value(), error(nil)
|
if slice, ok := f.Value.(*StringSlice); ok {
|
||||||
if err != nil {
|
return slice.Value()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return parsed
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user