forked from mirror/go-json
Fix decoding of []byte type
This commit is contained in:
parent
397a4e45d3
commit
2aeb1769a2
|
@ -49,10 +49,11 @@ func (d *bytesDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) er
|
||||||
}
|
}
|
||||||
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
|
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
|
||||||
buf := make([]byte, decodedLen)
|
buf := make([]byte, decodedLen)
|
||||||
if _, err := base64.StdEncoding.Decode(buf, bytes); err != nil {
|
n, err := base64.StdEncoding.Decode(buf, bytes)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
*(*[]byte)(p) = buf
|
*(*[]byte)(p) = buf[:n]
|
||||||
s.reset()
|
s.reset()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue