]> git.nihav.org Git - nihav.git/commitdiff
codec_support/h263: validate that B-frame has enough reference data
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 4 Apr 2020 10:27:55 +0000 (12:27 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 4 Apr 2020 10:27:55 +0000 (12:27 +0200)
nihav-codec-support/src/codecs/h263/decoder.rs

index 7a888821576d1ade73f60bce064ebc1debeb1fab..02d6075aa1d04aece3534a13304804f04b862779 100644 (file)
@@ -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 }