Skip to content

Commit fdaa7e2

Browse files
committed
lz4stream/block: compute block checksum on the block not its source.
Fixes #223.
1 parent 294e765 commit fdaa7e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/lz4stream/block.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (b *FrameDataBlock) Compress(f *Frame, src []byte, level lz4block.Compressi
246246
b.src = src // keep track of the source for content checksum
247247

248248
if f.Descriptor.Flags.BlockChecksum() {
249-
b.Checksum = xxh32.ChecksumZero(src)
249+
b.Checksum = xxh32.ChecksumZero(b.Data)
250250
}
251251
return b
252252
}
@@ -328,7 +328,7 @@ func (b *FrameDataBlock) Uncompress(f *Frame, dst, dict []byte, sum bool) ([]byt
328328
dst = dst[:n]
329329
}
330330
if f.Descriptor.Flags.BlockChecksum() {
331-
if c := xxh32.ChecksumZero(dst); c != b.Checksum {
331+
if c := xxh32.ChecksumZero(b.data); c != b.Checksum {
332332
err := fmt.Errorf("%w: got %x; expected %x", lz4errors.ErrInvalidBlockChecksum, c, b.Checksum)
333333
return nil, err
334334
}

0 commit comments

Comments
 (0)