craft-metafile: keep the outer file's decode budget for a nested PICT

A PICT inside another metafile now draws on that file's decode budget
instead of resetting it. The public PICT entry point still starts a
fresh budget.
This commit is contained in:
FredApps
2026-11-23 05:58:16 +07:00
parent 5153451938
commit 77807fd1be
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -265,7 +265,7 @@ pub(crate) fn parse_nested(bytes: &[u8]) -> Result<Picture, Error> {
// the WMF's own records (its dx rounding shows), so the copy is not used.
wmf::parse(b)?
} else if pict::is_pict(bytes) {
return pict::parse(bytes);
return pict::parse_nested(bytes);
} else {
return Err(Error::NotMetafile);
};
+5
View File
@@ -1440,6 +1440,11 @@ fn qt_image(d: &[u8]) -> Option<([u8; 4], Affine, Rect, &[u8])> {
/// Read a QuickDraw picture.
pub fn parse(bytes: &[u8]) -> Result<Picture, Error> {
crate::dib::set_decode_budget(crate::dib::MAX_DECODE_PIXELS);
parse_nested(bytes)
}
/// [`parse`] for a picture inside the metafile being parsed: it draws on the outer file's decode budget.
pub(crate) fn parse_nested(bytes: &[u8]) -> Result<Picture, Error> {
let h = find(bytes).ok_or(Error::NotPict)?;
let mut q = Pict::new(h.frame);
let mut r = Be::new(bytes, h.ops);