diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index fab3fb5b77..d5acb2bd39 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -887,6 +887,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, } if (i >= CFRAME_BUFFER_COUNT) { + if (free_index < 0) + return AVERROR_INVALIDDATA; i = free_index; f->cfrm[i].id = id; }