Merge pull request #2986 from 13r0ck/tiny_skia/zero-size-image

Fix #2877: tiny_skia: crash when zero width/height image
This commit is contained in:
Héctor 2025-11-29 01:56:28 +01:00 committed by GitHub
commit 89b8a43731
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -348,6 +348,9 @@ pub enum Error {
/// Loading images is unsupported.
#[error("loading images is unsupported")]
Unsupported,
/// The image is empty.
#[error("the image is empty")]
Empty,
/// Not enough memory to allocate the image.
#[error("not enough memory to allocate the image")]
OutOfMemory,

View file

@ -106,6 +106,10 @@ impl Cache {
}
};
if image.width() == 0 || image.height() == 0 {
return Err(raster::Error::Empty);
}
let mut buffer =
vec![0u32; image.width() as usize * image.height() as usize];