mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
std.compress.zstd: ensure window size fits into usize
This commit is contained in:
parent
7a7d6a02a5
commit
d034f2a87b
@ -380,7 +380,7 @@ pub const FrameContext = struct {
|
|||||||
/// - `error.WindowSizeUnknown` if the frame does not have a valid window
|
/// - `error.WindowSizeUnknown` if the frame does not have a valid window
|
||||||
/// size
|
/// size
|
||||||
/// - `error.WindowTooLarge` if the window size is larger than
|
/// - `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
|
/// - `error.ContentSizeTooLarge` if the frame header indicates a content
|
||||||
/// size larger than `std.math.maxInt(usize)`
|
/// size larger than `std.math.maxInt(usize)`
|
||||||
pub fn init(
|
pub fn init(
|
||||||
@ -395,7 +395,7 @@ pub const FrameContext = struct {
|
|||||||
const window_size = if (window_size_raw > window_size_max)
|
const window_size = if (window_size_raw > window_size_max)
|
||||||
return error.WindowTooLarge
|
return error.WindowTooLarge
|
||||||
else
|
else
|
||||||
@as(usize, @intCast(window_size_raw));
|
std.math.cast(usize, window_size_raw) orelse return error.WindowTooLarge;
|
||||||
|
|
||||||
const should_compute_checksum =
|
const should_compute_checksum =
|
||||||
frame_header.descriptor.content_checksum_flag and verify_checksum;
|
frame_header.descriptor.content_checksum_flag and verify_checksum;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user