avcodec/rangecoder: Test for invalid corner case
[ffmpeg.git] / libavcodec / rangecoder.c
index 9c6ef75..d7a2774 100644 (file)
@@ -58,6 +58,10 @@ av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf,
 
     c->low         = AV_RB16(c->bytestream);
     c->bytestream += 2;
+    if (c->low >= 0xFF00) {
+        c->low = 0xFF00;
+        c->bytestream_end = c->bytestream + 2;
+    }
 }
 
 void ff_build_rac_states(RangeCoder *c, int factor, int max_p)