aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Wolenetz <wolenetz@google.com>2018-04-10 13:59:25 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2018-07-10 01:52:55 +0200
commit54bde32f37fd69c556c1c65047f9d27c2a6da229 (patch)
tree2e9d301a928ea9ca668f0c150fdc5d73e8414d58
parent07cd51f10e96a4b9208d3aa99caea1068f89041b (diff)
downloadffmpeg-54bde32f37fd69c556c1c65047f9d27c2a6da229.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> (cherry picked from commit e43e97f0e0f0596b56ceb2f887fe7414f202f081) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/libopusdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index 7a198c46a0..4b8167d394 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -125,7 +125,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;
}
@@ -199,6 +202,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 },