diff --git a/snappy.go b/snappy.go index b76fdb219..8cdfb01f7 100644 --- a/snappy.go +++ b/snappy.go @@ -17,14 +17,17 @@ func snappyEncode(src []byte) ([]byte, error) { func snappyDecode(src []byte) ([]byte, error) { if bytes.Equal(src[:8], snappyMagic) { var ( - pos = uint32(16) - max = uint32(len(src)) - dst []byte + pos = uint32(16) + max = uint32(len(src)) + dst = make([]byte, 0, len(src)) + chunk []byte + err error ) for pos < max { size := binary.BigEndian.Uint32(src[pos : pos+4]) pos = pos + 4 - chunk, err := snappy.Decode(nil, src[pos:pos+size]) + + chunk, err = snappy.Decode(chunk, src[pos:pos+size]) if err != nil { return nil, err }