diff --git a/crates/ec-av1-syntax/src/frame.rs b/crates/ec-av1-syntax/src/frame.rs index b65b28b4..3228bc71 100644 --- a/crates/ec-av1-syntax/src/frame.rs +++ b/crates/ec-av1-syntax/src/frame.rs @@ -793,6 +793,12 @@ pub(crate) fn parse_uncompressed_header( h.display_frame_id = r.read_bits(id_len)?; } let slot = state.refs[h.frame_to_show_map_idx as usize]; + if !slot.valid { + return Err(Error::corrupt(format!( + "AV1 show_existing_frame shows empty slot {}", + h.frame_to_show_map_idx + ))); + } h.frame_type = slot.frame_type; h.frame_is_intra = matches!(h.frame_type, FrameType::Key | FrameType::IntraOnly); h.show_frame = true; @@ -950,6 +956,12 @@ pub(crate) fn parse_uncompressed_header( if !h.frame_refs_short_signaling { h.ref_frame_idx[i] = r.read_bits(3)? as u8; } + if !state.refs[h.ref_frame_idx[i] as usize].valid { + return Err(Error::corrupt(format!( + "AV1 inter frame references empty slot {}", + h.ref_frame_idx[i] + ))); + } if seq.frame_id_numbers_present_flag { h.delta_frame_id[i] = r.read_bits(seq.delta_frame_id_length)? + 1; }