From patchwork Thu Feb 10 12:20:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 34217 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:14aa:0:0:0:0 with SMTP id bz10csp2272523nkb; Thu, 10 Feb 2022 04:22:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7exbR8n9A7PP6d5eJ1vi2eZhLn+54CxnrWW8VTOen07/+k0AJiakpC1A99SJWkDUKDRS0 X-Received: by 2002:a17:907:7212:: with SMTP id dr18mr6080035ejc.681.1644495749285; Thu, 10 Feb 2022 04:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644495749; cv=none; d=google.com; s=arc-20160816; b=xqgsWgqB9QBKEnEITcpaqYwfFkGGwMfleojK6pfKJ73WY93ZIGlF5FAGCx7C9zOShX jlcY2JZcK0j3ik29v8Uxqy6+yAsmRXinW06kr9OqJ/iv+aGify+p95llZTBg2ST+Bikl MFG6u6XOIg/GldXR0FUUoU7cjHtge87abvTMiyagIJadTZtHn8z5Ych8A632+vKtqUrX 9utS+W7ArAQdRWidQ2sKM47gkljwrNQwtyIQ4ubdSIOndsp353D6yauxN/Ybii0BhiQR NclnKOUa8ZT+SscE7NBV0bMIKY83wWyLteopAvcnrytUGplYPtD4GIq4ZV9GU5GwznV+ Yzrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:message-id:date :to:from:delivered-to; bh=hIVHbBhPGs+FWbkgwaQVxtr/8yIGcGEVlP8tvrX73Fk=; b=RpoXJ79fzN9dWiBa8D4gJ+8nIld8rjThTuY2U4uwRMIvmqlODhmgMA5uA0lFN03nJX B3AiqCk8hl0d6mzDEDbPf6A1c8Mjo8NxPMKzKrExJTwNu+2IPotsDyNuvGy1d58COwev RtxRNMCPUg6HaqPS0Og/JwfAOKUPsTCqSpRWIaXdH2KTdLJfXsTCNyygdmIUk5NQWdx0 pBcEihQs0ntuLP3sONwBu6dRIGntYBGHoj/eDKOIW0vBn6maVzf58AhbeH+1o4wlqFo6 X11LantBcE3ggKNxyIa4S3oyWS7jYrN9fD7yQ2EMl9rEqHg/p7bVl0o3TFEIIqaO6+Mv E5Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ho14si4394280ejc.687.2022.02.10.04.22.28; Thu, 10 Feb 2022 04:22:29 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38ABC68B0A7; Thu, 10 Feb 2022 14:22:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DGdgmp3TwdLw 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);