Fix panic when drawing empty image in iced_tiny_skia
This commit is contained in:
parent
4f6ccb78fe
commit
dd1ff34697
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