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

avcodec/bink: Fix memleak upon init failure

The init function first allocates an AVFrame and then some buffers; if
one of the buffers couldn't be allocated, the AVFrame leaks. Solve this
by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

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-09-04 17:49:16 +02:00
parent 912785572a
commit 4f67288948

View File

@ -1381,10 +1381,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_hpeldsp_init(&c->hdsp, avctx->flags);
ff_binkdsp_init(&c->binkdsp);
if ((ret = init_bundles(c)) < 0) {
free_bundles(c);
if ((ret = init_bundles(c)) < 0)
return ret;
}
if (c->version == 'b') {
if (!binkb_initialised) {
@ -1424,4 +1422,5 @@ AVCodec ff_bink_decoder = {
.decode = decode_frame,
.flush = flush,
.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};