aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/cabac.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/cabac.c')
-rw-r--r--libavcodec/cabac.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index 8cc9333e09..f298336ea4 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -51,7 +51,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;
@@ -64,6 +64,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;
}
void ff_init_cabac_states(void)