authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2025-03-31 16:24:37+11:00
committergravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2025-03-31 17:22:44+11:00
logd034f2a87b24620cdd92a93ae35755222a8f26a7
tree79b27cd8612d9ed5f351ce15aa873f3e5f9e5023
parent7a7d6a02a58f78d19769829df74f911448ebc3d7

std.compress.zstd: ensure window size fits into usize


1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/compress/zstandard/decompress.zig+2-2
......@@ -380,7 +380,7 @@ pub const FrameContext = struct {
380380 /// - `error.WindowSizeUnknown` if the frame does not have a valid window
381381 /// size
382382 /// - `error.WindowTooLarge` if the window size is larger than
383 /// `window_size_max`
383 /// `window_size_max` or `std.math.intMax(usize)`
384384 /// - `error.ContentSizeTooLarge` if the frame header indicates a content
385385 /// size larger than `std.math.maxInt(usize)`
386386 pub fn init(
......@@ -395,7 +395,7 @@ pub const FrameContext = struct {
395395 const window_size = if (window_size_raw > window_size_max)
396396 return error.WindowTooLarge
397397 else
398 @as(usize, @intCast(window_size_raw));
398 std.math.cast(usize, window_size_raw) orelse return error.WindowTooLarge;
399399
400400 const should_compute_checksum =
401401 frame_header.descriptor.content_checksum_flag and verify_checksum;