aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/options.c
diff options
context:
space:
mode:
authorAndrey Turkin <andrey.turkin@gmail.com>2016-05-25 14:16:14 +0300
committerAnton Khirnov <anton@khirnov.net>2016-05-26 15:40:05 +0200
commit24b5cff01bbac4e08acfd6d19c499e880988f520 (patch)
tree0b8a7a42dc1238559040e2697007bceddc964062 /libavcodec/options.c
parent4024b566d664a4b161d677554be52f32e7ad4236 (diff)
downloadffmpeg-24b5cff01bbac4e08acfd6d19c499e880988f520.tar.gz
lavc: handle hw_frames_ctx where necessary
avcodec_copy_context() didn't handle hw_frames_ctx references correctly which could cause crashes. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/options.c')
-rw-r--r--libavcodec/options.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 117ae5e445..18613ace96 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -190,6 +190,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
dest->inter_matrix = NULL;
dest->rc_override = NULL;
dest->subtitle_header = NULL;
+ dest->hw_frames_ctx = NULL;
#if FF_API_MPV_OPT
FF_DISABLE_DEPRECATION_WARNINGS
dest->rc_eq = NULL;
@@ -219,13 +220,21 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
dest->subtitle_header_size = src->subtitle_header_size;
#undef alloc_and_copy_or_fail
+ if (src->hw_frames_ctx) {
+ dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
+ if (!dest->hw_frames_ctx)
+ goto fail;
+ }
+
return 0;
fail:
+ av_freep(&dest->subtitle_header);
av_freep(&dest->rc_override);
av_freep(&dest->intra_matrix);
av_freep(&dest->inter_matrix);
av_freep(&dest->extradata);
+ av_buffer_unref(&dest->hw_frames_ctx);
#if FF_API_MPV_OPT
FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&dest->rc_eq);