X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fjvdec.c;h=6f10157b0d89f85b41ba93d7a0d7ca8c110f6521;hb=339af976b6fd9c05d1e75e75a5323efdb3d6afa1;hp=cbe83d3c108d10a686eb91fdc5a779110d08f39a;hpb=b14761d1f8372dfe558193b8b754b9f1a858077d;p=ffmpeg diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index cbe83d3c108..6f10157b0d8 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -163,13 +163,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, av_log(avctx, AV_LOG_ERROR, "video size %d invalid\n", video_size); return AVERROR_INVALIDDATA; } - if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) - return ret; if (video_type == 0 || video_type == 1) { GetBitContext gb; init_get_bits(&gb, buf, 8 * video_size); + if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) + return ret; + + if (avctx->height/8 * (avctx->width/8) > 4 * video_size) { + av_log(avctx, AV_LOG_ERROR, "Insufficient input data for dimensions\n"); + return AVERROR_INVALIDDATA; + } + for (j = 0; j < avctx->height; j += 8) for (i = 0; i < avctx->width; i += 8) decode8x8(&gb, @@ -179,6 +185,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += video_size; } else if (video_type == 2) { int v = *buf++; + + av_frame_unref(s->frame); + if ((ret = ff_get_buffer(avctx, s->frame, AV_GET_BUFFER_FLAG_REF)) < 0) + return ret; + for (j = 0; j < avctx->height; j++) memset(s->frame->data[0] + j * s->frame->linesize[0], v, avctx->width);