Skip to content

Commit

Permalink
marshal: prevent calling IsNil on non nullable types (apache#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrischmann authored and Zariel committed Jan 22, 2019
1 parent 70385f8 commit 49a367b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1478,15 +1478,16 @@ func marshalMap(info TypeInfo, value interface{}) ([]byte, error) {
}

rv := reflect.ValueOf(value)
if rv.IsNil() {
return nil, nil
}

t := rv.Type()
if t.Kind() != reflect.Map {
return nil, marshalErrorf("can not marshal %T into %s", value, info)
}

if rv.IsNil() {
return nil, nil
}

buf := &bytes.Buffer{}
n := rv.Len()

Expand Down

0 comments on commit 49a367b

Please sign in to comment.