1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/mss3: Cleanup generically after init failure

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-08-29 08:51:55 +02:00
parent c1d3b4705e
commit 3a76076513

View File

@ -844,19 +844,13 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
b_width * b_height); b_width * b_height);
if (!c->dct_coder[i].prev_dc) { if (!c->dct_coder[i].prev_dc) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n"); av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
while (i >= 0) {
av_freep(&c->dct_coder[i].prev_dc);
i--;
}
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
} }
c->pic = av_frame_alloc(); c->pic = av_frame_alloc();
if (!c->pic) { if (!c->pic)
mss3_decode_end(avctx);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@ -875,4 +869,5 @@ AVCodec ff_msa1_decoder = {
.close = mss3_decode_end, .close = mss3_decode_end,
.decode = mss3_decode_frame, .decode = mss3_decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}; };