[FFmpeg-cvslog] avutil/hwcontext: verify hw_frames_ctx in transfer_data_alloc

Zhao Zhili git at videolan.org
Mon Nov 21 18:05:34 EET 2022


ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Sat Oct 22 05:29:35 2022 +0000| [b7a3f169578cb6c8281afe33dd879df7d1029d6c] | committer: Zhao Zhili

avutil/hwcontext: verify hw_frames_ctx in transfer_data_alloc

Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7a3f169578cb6c8281afe33dd879df7d1029d6c
---

 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);



More information about the ffmpeg-cvslog mailing list