提交 24b5cff0 编写于 作者: A Andrey Turkin 提交者: Anton Khirnov

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: NAnton Khirnov <anton@khirnov.net>
上级 4024b566
...@@ -190,6 +190,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) ...@@ -190,6 +190,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
dest->inter_matrix = NULL; dest->inter_matrix = NULL;
dest->rc_override = NULL; dest->rc_override = NULL;
dest->subtitle_header = NULL; dest->subtitle_header = NULL;
dest->hw_frames_ctx = NULL;
#if FF_API_MPV_OPT #if FF_API_MPV_OPT
FF_DISABLE_DEPRECATION_WARNINGS FF_DISABLE_DEPRECATION_WARNINGS
dest->rc_eq = NULL; dest->rc_eq = NULL;
...@@ -219,13 +220,21 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) ...@@ -219,13 +220,21 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
dest->subtitle_header_size = src->subtitle_header_size; dest->subtitle_header_size = src->subtitle_header_size;
#undef alloc_and_copy_or_fail #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; return 0;
fail: fail:
av_freep(&dest->subtitle_header);
av_freep(&dest->rc_override); av_freep(&dest->rc_override);
av_freep(&dest->intra_matrix); av_freep(&dest->intra_matrix);
av_freep(&dest->inter_matrix); av_freep(&dest->inter_matrix);
av_freep(&dest->extradata); av_freep(&dest->extradata);
av_buffer_unref(&dest->hw_frames_ctx);
#if FF_API_MPV_OPT #if FF_API_MPV_OPT
FF_DISABLE_DEPRECATION_WARNINGS FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&dest->rc_eq); av_freep(&dest->rc_eq);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册