Skip to content

Commit

Permalink
check nil data
Browse files Browse the repository at this point in the history
  • Loading branch information
shamaton committed Aug 4, 2021
1 parent 85f28ad commit e325f82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/decoding/decoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type decoder struct {
func Decode(data []byte, v interface{}, asArray bool) error {
d := decoder{data: data, asArray: asArray}

if d.data == nil {
return fmt.Errorf("data is nil")
}

rv := reflect.ValueOf(v)
if rv.Kind() != reflect.Ptr {
return fmt.Errorf("holder must set pointer value. but got: %t", v)
Expand Down

0 comments on commit e325f82

Please sign in to comment.