Skip to content

Commit

Permalink
Fix panic: reflect: call of reflect.Value.Interface on zero Value
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Jun 1, 2020
1 parent 2288b1c commit e95f2fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,10 @@ func (d *Decoder) decodeMap(dst reflect.Value, src ast.Node) error {
if k.IsValid() && k.Type().ConvertibleTo(keyType) {
k = k.Convert(keyType)
}
if err := d.validateMapKey(keyMap, k.Interface(), key); err != nil {
return errors.Wrapf(err, "invalid map key")
if k.IsValid() {
if err := d.validateMapKey(keyMap, k.Interface(), key); err != nil {
return errors.Wrapf(err, "invalid map key")
}
}
if valueType.Kind() == reflect.Ptr && value.Type() == ast.NullType {
// set nil value to pointer
Expand Down

0 comments on commit e95f2fb

Please sign in to comment.