diff --git a/crates/ec-dv/src/video.rs b/crates/ec-dv/src/video.rs index 8742bf01..662d2539 100644 --- a/crates/ec-dv/src/video.rs +++ b/crates/ec-dv/src/video.rs @@ -350,8 +350,11 @@ impl DvVideoDecoder { }) }) .collect(); - handles.into_iter().map(|h| h.join().expect("DV segment worker panicked")).collect() - }); + handles + .into_iter() + .map(|h| h.join().map_err(|_| Error::corrupt("DV: segment worker panicked"))) + .collect::>>() + })?; for o in &outs { o.apply(&mut planes); } diff --git a/crates/ec-dvbsub/src/lib.rs b/crates/ec-dvbsub/src/lib.rs index 952d3959..cf713ddd 100644 --- a/crates/ec-dvbsub/src/lib.rs +++ b/crates/ec-dvbsub/src/lib.rs @@ -351,8 +351,8 @@ impl DvbSubDecoder { } let id = b[0]; let fill = b[1] & 0x08 != 0; - let w = be16(b, 2).unwrap() as u32; - let h = be16(b, 4).unwrap() as u32; + let w = be16(b, 2).ok_or_else(|| Error::corrupt("dvbsub: short region composition"))? as u32; + let h = be16(b, 4).ok_or_else(|| Error::corrupt("dvbsub: short region composition"))? as u32; if w == 0 || h == 0 || w > MAX_DIMENSION || h > MAX_DIMENSION { return Err(Error::corrupt("dvbsub: region size out of range")); } @@ -375,10 +375,10 @@ impl DvbSubDecoder { let mut objects = Vec::new(); let mut at = 10; while at + 6 <= b.len() { - let oid = be16(b, at).unwrap() as u16; + let oid = be16(b, at).ok_or_else(|| Error::corrupt("dvbsub: short region object"))? as u16; let kind = b[at + 2] >> 6; - let x = (be16(b, at + 2).unwrap() & 0xFFF) as u32; - let y = (be16(b, at + 4).unwrap() & 0xFFF) as u32; + let x = (be16(b, at + 2).ok_or_else(|| Error::corrupt("dvbsub: short region object"))? & 0xFFF) as u32; + let y = (be16(b, at + 4).ok_or_else(|| Error::corrupt("dvbsub: short region object"))? & 0xFFF) as u32; objects.push((oid, x, y)); at += if kind == 1 || kind == 2 { 8 } else { 6 }; } @@ -435,7 +435,7 @@ impl DvbSubDecoder { if b.len() < 3 { return Err(Error::corrupt("dvbsub: short object")); } - let oid = be16(b, 0).unwrap() as u16; + let oid = be16(b, 0).ok_or_else(|| Error::corrupt("dvbsub: short object"))? as u16; let method = (b[2] >> 2) & 3; if method != 0 { return Ok(()); // character-coded objects are not bitmaps