[FFmpeg-cvslog] lavc/libopusdec: Allow avcodec_open2 to call .close
Matt Wolenetz
git at videolan.org
Fri Apr 13 02:58:39 EEST 2018
ffmpeg | branch: release/3.3 | Matt Wolenetz <wolenetz at google.com> | Tue Apr 10 13:59:25 2018 -0700| [9b1a4da668999c0bd4d78b370872b9448cf746c3] | committer: Michael Niedermayer
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 at niedermayer.cc>
(cherry picked from commit e43e97f0e0f0596b56ceb2f887fe7414f202f081)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b1a4da668999c0bd4d78b370872b9448cf746c3
---
libavcodec/libopusdec.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index e6ca61a78f..806ca1863d 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -126,7 +126,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;
}
@@ -200,6 +203,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 },
More information about the ffmpeg-cvslog
mailing list