diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 2a766b33f7..93fd0f4d50 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -91,6 +91,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, // we just ignore it bytestream_get_le16(&buf); + if (buf_end - buf < h + 3*4) + return AVERROR_INVALIDDATA; + // allocate sub and set values sub->rects = av_mallocz(sizeof(*sub->rects)); if (!sub->rects)