diff options
author | Matt Wolenetz <wolenetz@google.com> | 2018-04-10 13:59:25 -0700 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-04-11 02:42:41 +0200 |
commit | e43e97f0e0f0596b56ceb2f887fe7414f202f081 (patch) | |
tree | 8c8a92630cdd80373bde4a6086f8f34839f33fa2 /libavcodec/libopusdec.c | |
parent | aea610b0d6497886860a894eb76a6cc7788c0fcd (diff) | |
download | ffmpeg-e43e97f0e0f0596b56ceb2f887fe7414f202f081.tar.gz |
lavc/libopusdec: Allow avcodec_open2 to call .close
If there is a decoder initialization failure detected in avcodec_open2
after .init is called, allow graceful decoder .close to prevent leaking
libopus decoder allocations.
BUG=828526
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/libopusdec.c')
-rw-r--r-- | libavcodec/libopusdec.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index 3d2ee5b61b..2a97811d18 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -160,7 +160,10 @@ static av_cold int libopus_decode_close(AVCodecContext *avc) { struct libopus_context *opus = avc->priv_data; - opus_multistream_decoder_destroy(opus->dec); + if (opus->dec) { + opus_multistream_decoder_destroy(opus->dec); + opus->dec = NULL; + } return 0; } @@ -252,6 +255,7 @@ AVCodec ff_libopus_decoder = { .decode = libopus_decode, .flush = libopus_flush, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, |