zstd.Decompress: Assert buffer length requirements as early as possible

Without this assert, providing a buffer that's smaller than required results in more cryptic assertion failures later on.
This commit is contained in:
Ryan Liptak 2025-09-02 02:26:01 -07:00 committed by Andrew Kelley
parent bc7955306e
commit f872dd03da

View File

@ -92,6 +92,7 @@ const indirect_vtable: Reader.VTable = .{
///
/// Otherwise, `buffer` has those requirements.
pub fn init(input: *Reader, buffer: []u8, options: Options) Decompress {
if (buffer.len != 0) assert(buffer.len >= options.window_len + zstd.block_size_max);
return .{
.input = input,
.state = .new_frame,