PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
fix(create): keep the TIFF total budget in range on 32-bit targets
aionggc704c1089aa4
diff --git a/crates/create/src/lib.rs b/crates/create/src/lib.rsindex 33093e74c..7d1fdfc36 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<Vec<Embedded>, CreateError> {