diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c index 463e4ac661..e4507e5b42 100644 --- a/libavcodec/bintext.c +++ b/libavcodec/bintext.c @@ -54,6 +54,11 @@ static av_cold int decode_init(AVCodecContext *avctx) s->font_height = p[0]; s->flags = p[1]; p += 2; + if(avctx->extradata_size < 2 + (!!(s->flags & BINTEXT_PALETTE))*3*16 + + (!!(s->flags & BINTEXT_FONT))*s->font_height*256) { + av_log(avctx, AV_LOG_ERROR, "not enough extradata\n"); + return AVERROR_INVALIDDATA; + } } else { s->font_height = 8; s->flags = 0;