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 Some(ret) = self.entries.get(&id).unwrap().as_ref().map(|entry| {
tiny_skia::PixmapRef::from_bytes(
bytemuck::cast_slice(&entry.pixels),
entry.width,
entry.height,
)
.expect("Build pixmap from image bytes")
}) else {
return Err(raster::Error::Empty);
};
Ok(self
.entries
.get(&id)
.unwrap()
.as_ref()
.map(|entry| {
tiny_skia::PixmapRef::from_bytes(
bytemuck::cast_slice(&entry.pixels),
entry.width,
entry.height,
)
.expect("Build pixmap from image bytes")
})
.expect("Image should be allocated"))
Ok(ret)
}
fn trim(&mut self) {