From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A4E3040EF6 for ; Thu, 10 Feb 2022 12:22:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01B2F68B1D0; Thu, 10 Feb 2022 14:22:17 +0200 (EET) Received: from smtpbg587.qq.com (smtpbg126.qq.com [106.55.201.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92B2D68B178 for ; Thu, 10 Feb 2022 14:22:09 +0200 (EET) X-QQ-mid: bizesmtp42t1644495652ty1hepo6 Received: from localhost (unknown [103.107.216.231]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 10 Feb 2022 20:20:51 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0000000 X-QQ-FEAT: F3yR32iATbgQr40nhlBRS8qaGGmGbOeADK4P3K1zfmnKBAJ7daIZXypOt/Jw0 Bym8oBsLOo93OB6hreEM3DDt2CbewZa9afknitR7d28codjR6m4Sy5MphZ5357/Nv2Fc3bO FWpq5u7BodoSoF8yOzdQwsVolZtZEPVfX/AtV1ADUeBxhKBlExYIuHXTm0VIXqqPLVhYAsL TpNY9PKBw7zUQGNhPs4L5K5G51pTUD2M5YbhXjopFdJadKQlyqqDfqUqdTt5Gu+cLpmRcXT yJ0/nmADkEHtsegcz4DwOYTtfHsAXe/oMl0ofrkPvuarG7NXcOK0PoXO0= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Feb 2022 20:20:49 +0800 Message-Id: <20220210122049.70641-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgspam:qybgspam2 Subject: [FFmpeg-devel] [PATCH] avutil/hwcontext: check the null pointer input value before use it X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: because the src, src->hw_frames_ctx and src->hw_frames_ctx->data can be set to null when the user calling av_hwframe_transfer_data, this will get crash if they are null. Signed-off-by: Steven Liu --- libavutil/hwcontext.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 31c7840dba..b42a3a6d4d 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -396,10 +396,13 @@ 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 = NULL; AVFrame *frame_tmp; int ret = 0; + if (!src || !src->hw_frames_ctx || !src->hw_frames_ctx->data) + return AVERROR(EINVAL); + ctx = (AVHWFramesContext*)src->hw_frames_ctx->data; frame_tmp = av_frame_alloc(); if (!frame_tmp) return AVERROR(ENOMEM); -- 2.25.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".