mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Palette PNG indices: the memory check counts whole tiles and the row buffer
This commit is contained in:
1 parent
5c1357b46d
commit
3d11c5fc52
1 file changed
+2
-1
@@ -294,7 +294,8 @@ fn png_color_indices(bytes: &[u8], doc: &Document) -> Option<ColorIndices> {
|
||||
let width = usize::try_from(w).ok()?;
|
||||
let rows = usize::try_from(TILE_SIZE).ok()?;
|
||||
let band_len = width.checked_mul(rows)?;
|
||||
let needed = u64::from(w).checked_mul(u64::from(h))?.checked_add(u64::try_from(band_len).ok()?)?;
|
||||
// The index surface's whole tiles, the band, and the row of the layer read beside it.
|
||||
let needed = tile_bytes(w, h, 1).saturating_add(u64::from(w).saturating_mul(rows as u64 + 4));
|
||||
crate::memory::check_fits(w, h, needed, crate::memory::available()).ok()?;
|
||||
let mut band = Vec::new();
|
||||
band.try_reserve_exact(band_len).ok()?;
|
||||
|
||||
Reference in new issue
Block a user