address review: charge declared image pixels before decode

This commit is contained in:
Dylan M. Taylor
2026-11-03 12:58:58 +00:00
parent 1f90317268
commit d9c32f8bf8
+2 -1
View File
@@ -1058,9 +1058,10 @@ impl<'a> Interp<'a> {
self.b.skip("image (page pixel limit)");
return;
};
// Charged even when the decode fails: the declared size is what costs.
self.image_pixels = left;
match crate::image::decode(self.file, d, raw, Some(res), fill) {
Ok(img) => {
self.image_pixels = left;
let decoded = (img.width, img.height, std::sync::Arc::new(img.rgba));
if let Some(k) = cache_key {
self.images.insert(k, decoded.clone());