From df05c4383da3fc259763db9b905dff548e74e2be Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 4 Apr 2020 12:27:55 +0200 Subject: [PATCH] codec_support/h263: validate that B-frame has enough reference data --- nihav-codec-support/src/codecs/h263/decoder.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nihav-codec-support/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs index 7a88882..02d6075 100644 --- a/nihav-codec-support/src/codecs/h263/decoder.rs +++ b/nihav-codec-support/src/codecs/h263/decoder.rs @@ -213,6 +213,10 @@ impl H263BaseDecoder { } let is_b = pinfo.mode == Type::B; + if is_b && (self.mv_data.len() < self.mb_w * self.mb_h) { + return Err(DecoderError::MissingReference); + } + let tsdiff = if pinfo.is_pb() { pinfo.ts.wrapping_sub(self.last_ts) >> 1 } else { self.last_ts.wrapping_sub(self.next_ts) >> 1 }; let bsdiff = if pinfo.is_pb() { (pinfo.get_pbinfo().get_trb() as u16) << 7 } -- 2.39.5