From f872dd03da64e5b53d3a5c7a95344b5b64a7aacb Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Tue, 2 Sep 2025 02:26:01 -0700 Subject: [PATCH] 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. --- lib/std/compress/zstd/Decompress.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/compress/zstd/Decompress.zig b/lib/std/compress/zstd/Decompress.zig index 817aebb52b..0acef462e7 100644 --- a/lib/std/compress/zstd/Decompress.zig +++ b/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,