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 71A5247780 for ; Wed, 22 Nov 2023 04:08:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E3FE068CDE1; Wed, 22 Nov 2023 06:08:30 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE04368C5C7 for ; Wed, 22 Nov 2023 06:08:24 +0200 (EET) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 30B111060140 for ; Wed, 22 Nov 2023 04:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1700626103; 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=Tr5mVqmGqtI5pO7qb6rX069uhGSM2nO7VngUA0H+fT4=; b=QsM+Kxc/x4sMioBDBFSThqq7CTMMo2tHbOKjWZIvVdOiQ8DuZNXkmlSUZWQCOLr1 fq8Xq90zcmR6qa61qmye6ddbT80hnFM64UjV/sPkCqpdEQsPQm5ELz/thCK7gQURRLA VsMgOkxCdwL+E4cqauwJVPQDeQ1PKZw3iIShswJ/8vfeJAjKWF6yGLu++BOirUfsy0r wsKy1psazR28SXrnNdj8Lf3Sl7EYZStG6vh+UfsSafpzwrbYk/FzOTf+TDu/uftvMSm mc6MCujLV1t4d1ENk8RVTKSDeA/KPzhF8wAMX6DggvAYPez2PdnA5/lyQcK6tyWhnEC sWuKPglsuA== Date: Wed, 22 Nov 2023 05:08:23 +0100 (CET) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: 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, 07:02 by dmitry.v.rogozhkin-at-intel.com@ffmpeg.org: > On Tue, 2023-11-21 at 06:17 +0100, Lynne wrote: > >> 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_c >> > tx->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. >> > > Thank you for the catch. Yep, I did a type doing v3. Fixed now. See v5. > Pushed, thanks _______________________________________________ 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".