]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cabac.c
Merge commit 'd017ed878a45171f2f6c69fb9d76401c3c494110'
[ffmpeg] / libavcodec / cabac.c
index 598c9427984ffefe943696224358c625b9aba9d1..5bf5bc284ef8e0eec34c384394645beb2741dd93 100644 (file)
@@ -175,7 +175,7 @@ void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){
  *
  * @param buf_size size of buf in bits
  */
-void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
+int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
     c->bytestream_start=
     c->bytestream= buf;
     c->bytestream_end= buf + buf_size;
@@ -188,6 +188,9 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
 #endif
     c->low+= ((*c->bytestream++)<<2) + 2;
     c->range= 0x1FE;
+    if ((c->range<<(CABAC_BITS+1)) < c->low)
+        return AVERROR_INVALIDDATA;
+    return 0;
 }
 
 #ifdef TEST