summaryrefslogtreecommitdiff
path: root/libavcodec/avcodec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-18 05:26:32 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-24 13:56:43 +0200
commita1ed984e049c90122e80bd60c2028f9bb22cc31c (patch)
tree539d72740c7246efd7cd89681317e6065d938cd4 /libavcodec/avcodec.c
parent878e45e0fb261bda452a9b049570d4e7d3f4fa6c (diff)
downloadffmpeg-a1ed984e049c90122e80bd60c2028f9bb22cc31c.tar.gz
avcodec/avcodec: Actually honour the documentation of subtitle_header
It is only supposed to be freed by libavcodec for decoders, yet avcodec_open2() always frees it on failure. Furthermore, avcodec_close() doesn't free it for decoders. Both of this has been changed. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/avcodec.c')
-rw-r--r--libavcodec/avcodec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 760a98d8ef..24f6922d4f 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -418,7 +418,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_dict_free(&tmp);
av_freep(&avctx->priv_data);
- av_freep(&avctx->subtitle_header);
+ if (av_codec_is_decoder(avctx->codec))
+ av_freep(&avctx->subtitle_header);
#if FF_API_OLD_ENCDEC
av_frame_free(&avci->to_free);
@@ -589,7 +590,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
av_frame_free(&avctx->coded_frame);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- }
+ } else if (av_codec_is_decoder(avctx->codec))
+ av_freep(&avctx->subtitle_header);
+
avctx->codec = NULL;
avctx->active_thread_type = 0;