[FFmpeg-devel] [PATCH 11/12] avutil/hwcontext: verify hw_frames_ctx in transfer_data_alloc

Zhao Zhili quinkblack at foxmail.com
Mon Oct 24 06:16:57 EEST 2022


From: Zhao Zhili <zhilizhao at tencent.com>

---
 libavutil/hwcontext.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index ab9ad3703e..3396598269 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -397,10 +397,14 @@ int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ref,
 
 static int transfer_data_alloc(AVFrame *dst, const AVFrame *src, int flags)
 {
-    AVHWFramesContext *ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
+    AVHWFramesContext *ctx;
     AVFrame *frame_tmp;
     int ret = 0;
 
+    if (!src->hw_frames_ctx)
+        return AVERROR(EINVAL);
+    ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
+
     frame_tmp = av_frame_alloc();
     if (!frame_tmp)
         return AVERROR(ENOMEM);
-- 
2.25.1



More information about the ffmpeg-devel mailing list