zstandard: fix incorrect RLE decompression into ring buffer

This reverts a change introduced in #17400 causing a bug when
decompressing an RLE block into a ring buffer.

RLE blocks contain only a single byte of data to copy into the output,
so attempting to copy a slice causes buffer overruns and incorrect
decompression.
This commit is contained in:
dweiller 2023-11-03 17:09:29 +11:00 committed by Andrew Kelley
parent 1ccc68f307
commit f6de3ec963

View File

@ -721,7 +721,9 @@ pub fn decodeBlockRingBuffer(
},
.rle => {
if (src.len < 1) return error.MalformedRleBlock;
dest.writeSliceAssumeCapacity(src[0..block_size]);
for (0..block_size) |_| {
dest.writeAssumeCapacity(src[0]);
}
consumed_count.* += 1;
decode_state.written_count += block_size;
return block_size;