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:
commit
89b8a43731
2 changed files with 7 additions and 0 deletions
|
|
@ -348,6 +348,9 @@ pub enum Error {
|
||||||
/// Loading images is unsupported.
|
/// Loading images is unsupported.
|
||||||
#[error("loading images is unsupported")]
|
#[error("loading images is unsupported")]
|
||||||
Unsupported,
|
Unsupported,
|
||||||
|
/// The image is empty.
|
||||||
|
#[error("the image is empty")]
|
||||||
|
Empty,
|
||||||
/// Not enough memory to allocate the image.
|
/// Not enough memory to allocate the image.
|
||||||
#[error("not enough memory to allocate the image")]
|
#[error("not enough memory to allocate the image")]
|
||||||
OutOfMemory,
|
OutOfMemory,
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,10 @@ impl Cache {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if image.width() == 0 || image.height() == 0 {
|
||||||
|
return Err(raster::Error::Empty);
|
||||||
|
}
|
||||||
|
|
||||||
let mut buffer =
|
let mut buffer =
|
||||||
vec![0u32; image.width() as usize * image.height() as usize];
|
vec![0u32; image.width() as usize * image.height() as usize];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue