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> (cherry picked from commit 4f672889481e7b3dc03c04b02a86836e94104e63)
This commit is contained in:
parent
c71de42131
commit
7f1f850f11
@ -1381,10 +1381,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
ff_hpeldsp_init(&c->hdsp, avctx->flags);
|
ff_hpeldsp_init(&c->hdsp, avctx->flags);
|
||||||
ff_binkdsp_init(&c->binkdsp);
|
ff_binkdsp_init(&c->binkdsp);
|
||||||
|
|
||||||
if ((ret = init_bundles(c)) < 0) {
|
if ((ret = init_bundles(c)) < 0)
|
||||||
free_bundles(c);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (c->version == 'b') {
|
if (c->version == 'b') {
|
||||||
if (!binkb_initialised) {
|
if (!binkb_initialised) {
|
||||||
@ -1424,4 +1422,5 @@ AVCodec ff_bink_decoder = {
|
|||||||
.decode = decode_frame,
|
.decode = decode_frame,
|
||||||
.flush = flush,
|
.flush = flush,
|
||||||
.capabilities = AV_CODEC_CAP_DR1,
|
.capabilities = AV_CODEC_CAP_DR1,
|
||||||
|
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user