fix(tiny-skia): avoid panic if image is not allocated

This commit is contained in:
Ashley Wulber 2026-03-06 16:29:29 -05:00 • committed by Michael Murphy
parent ac24bbe80d
commit 5f97135c3d

View file

@ -152,21 +152,18 @@ impl Cache {
} }
let _ = self.hits.insert(id); let _ = self.hits.insert(id);
let Some(ret) = self.entries.get(&id).unwrap().as_ref().map(|entry| {
Ok(self
.entries
.get(&id)
.unwrap()
.as_ref()
.map(|entry| {
tiny_skia::PixmapRef::from_bytes( tiny_skia::PixmapRef::from_bytes(
bytemuck::cast_slice(&entry.pixels), bytemuck::cast_slice(&entry.pixels),
entry.width, entry.width,
entry.height, entry.height,
) )
.expect("Build pixmap from image bytes") .expect("Build pixmap from image bytes")
}) }) else {
.expect("Image should be allocated")) return Err(raster::Error::Empty);
};
Ok(ret)
} }
fn trim(&mut self) { fn trim(&mut self) {