X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fvb.c;h=fe419c766313a58c51a381d4874d46dee7afb148;hb=0a071f7124beaf0929f772a8618ac1b6c17b0222;hp=c6dd6fb4561e11a2004fb4707806b11355881e77;hpb=44085b9951b06df1cab4105dcda004213988d84f;p=ffmpeg diff --git a/libavcodec/vb.c b/libavcodec/vb.c index c6dd6fb4561..fe419c76631 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -199,6 +199,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, uint32_t size; int offset = 0; + if (avpkt->size < 2) + return AVERROR_INVALIDDATA; + bytestream2_init(&c->stream, avpkt->data, avpkt->size); if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) @@ -259,11 +262,8 @@ static av_cold int decode_init(AVCodecContext *avctx) c->frame = av_mallocz(avctx->width * avctx->height); c->prev_frame = av_mallocz(avctx->width * avctx->height); - if (!c->frame || !c->prev_frame) { - av_freep(&c->frame); - av_freep(&c->prev_frame); + if (!c->frame || !c->prev_frame) return AVERROR(ENOMEM); - } return 0; } @@ -288,4 +288,5 @@ AVCodec ff_vb_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };