X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fvb.c;h=f5b7f89853f1d861a81ae6c873356bc365f26952;hb=9e13df3776da3a101e895e2840f6f23f5a6f74a0;hp=c6dd6fb4561e11a2004fb4707806b11355881e77;hpb=a024c3ce9a502849013a4aa2c0a6de0c9270261c;p=ffmpeg diff --git a/libavcodec/vb.c b/libavcodec/vb.c index c6dd6fb4561..f5b7f89853f 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; } @@ -278,7 +278,7 @@ static av_cold int decode_end(AVCodecContext *avctx) return 0; } -AVCodec ff_vb_decoder = { +const AVCodec ff_vb_decoder = { .name = "vb", .long_name = NULL_IF_CONFIG_SMALL("Beam Software VB"), .type = AVMEDIA_TYPE_VIDEO, @@ -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, };