From c704c1089aa417fbc5e95975868fa4c044fc9e32 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 22 Oct 2026 21:55:12 +0000 Subject: [PATCH] fix(create): keep the TIFF total budget in range on 32-bit targets --- crates/create/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/create/src/lib.rs b/crates/create/src/lib.rs index 33093e74cd..7d1fdfc366 100644 --- a/crates/create/src/lib.rs +++ b/crates/create/src/lib.rs @@ -414,8 +414,9 @@ const MAX_GIF_PIXELS: u64 = 1 << 24; const MAX_DECODED_BYTES: usize = 2 << 30; /// Most decoded bytes all the pages of one TIFF may take together: its pages stay in memory until -/// they are embedded, and many small directories can share one compressed strip. -const MAX_DECODED_TOTAL: usize = 2 * MAX_DECODED_BYTES; +/// they are embedded, and many small directories can share one compressed strip. Saturates to the +/// whole address space on 32-bit targets (wasm32), where 4 GiB doesn't fit in `usize`. +const MAX_DECODED_TOTAL: usize = MAX_DECODED_BYTES.saturating_mul(2); /// The first `wanted` pages of a TIFF (multi-page scans become multi-page PDFs). fn tiff_pages(name: &str, bytes: &[u8], wanted: usize) -> Result, CreateError> {