aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authordweiller <4678790+dweiller@users.noreply.github.com>2025-03-31 16:24:37 +1100
committerdweiller <4678790+dweiller@users.noreply.github.com>2025-03-31 17:22:44 +1100
commitd034f2a87b24620cdd92a93ae35755222a8f26a7 (patch)
tree79b27cd8612d9ed5f351ce15aa873f3e5f9e5023 /lib/std
parent7a7d6a02a58f78d19769829df74f911448ebc3d7 (diff)
downloadzig-d034f2a87b24620cdd92a93ae35755222a8f26a7.tar.gz
zig-d034f2a87b24620cdd92a93ae35755222a8f26a7.zip
std.compress.zstd: ensure window size fits into usize
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/compress/zstandard/decompress.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/compress/zstandard/decompress.zig b/lib/std/compress/zstandard/decompress.zig
index 86be16268f..adc7b89749 100644
--- a/lib/std/compress/zstandard/decompress.zig
+++ b/lib/std/compress/zstandard/decompress.zig
@@ -380,7 +380,7 @@ pub const FrameContext = struct {
/// - `error.WindowSizeUnknown` if the frame does not have a valid window
/// size
/// - `error.WindowTooLarge` if the window size is larger than
- /// `window_size_max`
+ /// `window_size_max` or `std.math.intMax(usize)`
/// - `error.ContentSizeTooLarge` if the frame header indicates a content
/// size larger than `std.math.maxInt(usize)`
pub fn init(
@@ -395,7 +395,7 @@ pub const FrameContext = struct {
const window_size = if (window_size_raw > window_size_max)
return error.WindowTooLarge
else
- @as(usize, @intCast(window_size_raw));
+ std.math.cast(usize, window_size_raw) orelse return error.WindowTooLarge;
const should_compute_checksum =
frame_header.descriptor.content_checksum_flag and verify_checksum;