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 A0F2D482BD for ; Tue, 21 Nov 2023 05:17:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7E81268CA21; Tue, 21 Nov 2023 07:17:09 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE09368BAD0 for ; Tue, 21 Nov 2023 07:17:03 +0200 (EET) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 430D01060155 for ; Tue, 21 Nov 2023 05:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1700543822; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=WZUH99eg6C9KLGVwCPM/YCw8boU+Bd/JJZd73MiXfZs=; b=sF4Nq1l0x4S0owchIDv+nIURQk+H650oQMC0iJgBE4lqByVO2/NNgnQAT9RICOdW p8wvN7wvzXd1XOSOI3JFEXEPZU+rZBeFGiMV8pXVV1gxCJJbWX1Qm177cwtM2tdP0eT qZxeU6z20CY98sT2XwiWeHdZZ7KvXnz6TCKz0LCJbE2Qpx7gsr0Yh1uix6q3F8KPsre RVPDf7mbvUVH3Bfjrq5q6CH6DBTv02G7oOMRMbOdrO6daJy5UYqP8nqjBow94fSSVE/ WPRug2JOJJ2LXo5aqc5AnYL/dwOE7Ny3B2PCOOEU4S5xBxUJ3WDn9K48fQ3Hs1bNUgg mS3AnfncJA== Date: Tue, 21 Nov 2023 06:17:02 +0100 (CET) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: <1700541472-12254-1-git-send-email-dmitry.v.rogozhkin@intel.com-NjkA62m----9> References: <1699986151-24741-1-git-send-email-dmitry.v.rogozhkin@intel.com> <1700541472-12254-1-git-send-email-dmitry.v.rogozhkin@intel.com-NjkA62m----9> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v4] avcodec/decode: validate hw_frames_ctx when AVHWAccel.free_frame_priv is used 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-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: Nov 21, 2023, 05:38 by dmitry.v.rogozhkin-at-intel.com@ffmpeg.org: > Validate that a hw_frames_ctx is available before using it for > the AVHWAccel.free_frame_priv callback, and don't require it to > be present when the callback is not in use by the HWAccel. > > v2: check for free_frame_priv (Hendrik) > v3: return EINVAL (Christoph Reiter) > v4: better commit message (Hendrik) > > See[1]: https://github.com/msys2/MINGW-packages/pull/19050 > Fixes: be07145109 ("avcodec: add AVHWAccel.free_frame_priv callback") > CC: Lynne > CC: Christoph Reiter > Signed-off-by: Dmitry Rogozhkin > --- > libavcodec/decode.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index ad39021..50c3995 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -1838,17 +1838,25 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) > int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private) > { > const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel); > - AVHWFramesContext *frames_ctx; > > if (!hwaccel || !hwaccel->frame_priv_data_size) > return 0; > > av_assert0(!*hwaccel_picture_private); > > - frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; > - *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0, > - frames_ctx->device_ctx, > - hwaccel->free_frame_priv); > + if (hwaccel->free_frame_priv) { > + AVHWFramesContext *frames_ctx; > + > + if (!avctx->hw_frames_ctx) > + return AVERROR(EINVAL); > + > + *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0, > + frames_ctx->device_ctx, > + hwaccel->free_frame_priv); > + } else { > + *hwaccel_picture_private = ff_refstruct_allocz(hwaccel->frame_priv_data_size); > + } > + > if (!*hwaccel_picture_private) > return AVERROR(ENOMEM); > You never set frames_ctx in this patch. _______________________________________________ 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".