summaryrefslogtreecommitdiff
path: root/libavcodec/bink.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-04 17:49:16 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-04 20:37:12 +0200
commit4f672889481e7b3dc03c04b02a86836e94104e63 (patch)
tree93f6252da891d7c31b3ad4bf988df08f372431d1 /libavcodec/bink.c
parent912785572a77dc97d749e64a359e92c7d378ff4a (diff)
downloadffmpeg-4f672889481e7b3dc03c04b02a86836e94104e63.tar.gz
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>
Diffstat (limited to 'libavcodec/bink.c')
-rw-r--r--libavcodec/bink.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index f251ab4017..c7ef333bd4 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -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,
};