mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-02 03:22:37 +00:00
Fixes #9579 Protect against panics caused by integer overflows by using functions that allow integer overflows to be caught instead of causing a panic. Also protect against DOS from images that might not cause an overflow but do consume an absurd amount of memory by limiting images to a maximum size of 4GiB (which is the maximum size of `image-storage-limit`).
14 lines
429 B
Zig
14 lines
429 B
Zig
const std = @import("std");
|
|
|
|
const c = @import("c.zig").c;
|
|
|
|
pub const Error = std.mem.Allocator.Error || error{ WuffsError, Overflow };
|
|
|
|
pub fn check(log: anytype, status: *const c.struct_wuffs_base__status__struct) error{WuffsError}!void {
|
|
if (!c.wuffs_base__status__is_ok(status)) {
|
|
const e = c.wuffs_base__status__message(status);
|
|
log.warn("decode err={s}", .{e});
|
|
return error.WuffsError;
|
|
}
|
|
}
|