diff options
author | James Almer <jamrial@gmail.com> | 2017-04-24 14:53:47 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-05-17 16:26:06 -0300 |
commit | 676ba8eff86d2ed1e9eb14d09c87c7ed41cadc7f (patch) | |
tree | 1f33628311ead7623082569c23e56e514eaa6f9b | |
parent | cf44f0ae6a52d2c470861aeb938393cad3f047e6 (diff) | |
download | ffmpeg-676ba8eff86d2ed1e9eb14d09c87c7ed41cadc7f.tar.gz |
avcodec/options: do a more thorough clean up in avcodec_copy_context()
Free coded_frame and coded_side_data to prevent potential leaks.
Reviewed-by: Aaron Levinson <alevinsn@aracnet.com>
Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit cac8de2da5c4935773128335c11b806faa73e19d)
-rw-r--r-- | libavcodec/options.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c index 35098b864d..fb23ee6ad4 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -181,13 +181,24 @@ void avcodec_free_context(AVCodecContext **pavctx) static void copy_context_reset(AVCodecContext *avctx) { + int i; + av_opt_free(avctx); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + av_frame_free(&avctx->coded_frame); +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_freep(&avctx->rc_override); av_freep(&avctx->intra_matrix); av_freep(&avctx->inter_matrix); av_freep(&avctx->extradata); av_freep(&avctx->subtitle_header); + for (i = 0; i < avctx->nb_coded_side_data; i++) + av_freep(&avctx->coded_side_data[i].data); + av_freep(&avctx->coded_side_data); avctx->subtitle_header_size = 0; + avctx->nb_coded_side_data = 0; avctx->extradata_size = 0; } @@ -228,10 +239,12 @@ FF_ENABLE_DEPRECATION_WARNINGS /* reallocate values that should be allocated separately */ dest->extradata = NULL; + dest->coded_side_data = NULL; dest->intra_matrix = NULL; dest->inter_matrix = NULL; dest->rc_override = NULL; dest->subtitle_header = NULL; + dest->nb_coded_side_data = 0; #define alloc_and_copy_or_fail(obj, size, pad) \ if (src->obj && size > 0) { \ |