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 21C9740F08 for ; Thu, 10 Feb 2022 12:27:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7783F68AB7C; Thu, 10 Feb 2022 14:27:31 +0200 (EET) Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 05E7A68AED4 for ; Thu, 10 Feb 2022 14:27:25 +0200 (EET) Received: by mail-ot1-f48.google.com with SMTP id b17-20020a9d4791000000b005a17fc2dfc1so3673469otf.1 for ; Thu, 10 Feb 2022 04:27:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=yCsSTr2X1ivaOR1wFLA1mNve5yOHcTXW5MVrddP6bUY=; b=eVs5AfwIYffe/jdJHQ+q8ColloACojrqodZ6HufxAwLYtBRbCfhwfdtxixYgoLabgt Z/W1Mr+DMs8fLF3Uh2jxV6xKCJh0AHNdLcvSqBA5vh9eWtz7+nOphK2WXEHwb8NrYwap BljHrSsPWXRZfM/qKt9uAtI3aOd8hxLj/zwxH2uNYuYb+Y5a+OaWsBZy/zvWcsKN8VTN B49sQ1CfLTUrGrBgoy8Ho2fiwyFymOtJ/tud8bXb3lTcfJlagALZTqvALkqlQcfNHEea oWCUvG4aBACPdYNYsMITtsmDeZ8+572F4E21Xl8y+0lImT76yQV/dueM3JFRPYZpoPrG zltQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=yCsSTr2X1ivaOR1wFLA1mNve5yOHcTXW5MVrddP6bUY=; b=WTLDPjd7Y/MZLSkcwz6RrLWCmdJajfKj4qIPRlNEFLNrOVPDr0As0jaNNHWPUe2TZZ KyHTnvsv40lAyRrBikL1T0c26gGWFpTlW+wmVye/YgkwWDEi/XWT9KV12H/rM+E1lVo/ 3H0Mdz5ZyYQ5BL7u2w92Zk1S1GHiLwhi2F4HfkW0OhEQhn/UNTi/0QpOygKWA1WJO5L0 Ocf4A0y0k96zhArGOOA121qiSwtAid1UhhYqJ0b4Z/JLeysTzzH26vK3GZLM9lquFbom /haraPZtjqzwodiTU4Cy8TwD5mnXgJf9t1v3rl5O8KQMtnpq1zm6onAyqrQSsXXD8Hu8 41Ng== X-Gm-Message-State: AOAM532wQeRtK9KrpYo9UMmCrSTeXtObHFxaqHOM9vCSLj/yrp4n+bmN S5UQKI4rQULIGdJbeoshw8ElIJRAXskPhw== X-Google-Smtp-Source: ABdhPJxJJj9usKnvh9xGKnIpk8492pJcv4YRKm0HQGh2NnsimJZktle4+eraPp7a98z0pNNUNGGzsw== X-Received: by 2002:a9d:4794:: with SMTP id b20mr2777930otf.361.1644496042719; Thu, 10 Feb 2022 04:27:22 -0800 (PST) Received: from [192.168.0.10] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id t21sm7902252oor.4.2022.02.10.04.27.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Feb 2022 04:27:22 -0800 (PST) Message-ID: <877663ed-2b99-be67-2ebf-9c5303870a09@gmail.com> Date: Thu, 10 Feb 2022 09:27:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220210122049.70641-1-lq@chinaffmpeg.org> From: James Almer In-Reply-To: <20220210122049.70641-1-lq@chinaffmpeg.org> Subject: Re: [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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 2/10/2022 9:20 AM, Steven Liu wrote: > 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. src can not be NULL. The doxy doesn't allow it. And if transfer_data_alloc() is called, it's because dst is "clean", and src must then have a hw_frames_ctx (The doxy explicitly states "At least one of dst/src must have an AVHWFramesContext attached"). > > 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); _______________________________________________ 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".