Commit f872dd03da

Ryan Liptak <squeek502@hotmail.com>
2025-09-02 11:26:01
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.
1 parent bc79553
Changed files (1)
lib
std
compress
lib/std/compress/zstd/Decompress.zig
@@ -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,