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 4A44D43A7C for ; Wed, 6 Jul 2022 19:50:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4180868BABC; Wed, 6 Jul 2022 22:50:28 +0300 (EEST) Received: from btbn.de (btbn.de [136.243.74.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94CD268BAB0 for ; Wed, 6 Jul 2022 22:50:20 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id CEC8934BDB8; Wed, 6 Jul 2022 21:50:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1657137019; bh=NjPytgcci73A/SdvACKFfVvC72pm+MpFO1LURbVJDME=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GS18QhHANUleCR/79x3zMZ68EkNJgd96GQys5GkkGB6DV1ASc4rPjU2wgMh7/pUHn bWpQEEfIHEWDe14U1LRTowZSKvxaNbsA6f9Zrz1tsiBON+w0J3jHPOJWNyNPujkoqQ JgRVVwbNKDPfAtb0sJxWHqhPACKBkA5daEwnMu/8oIiewzjvJFsLguot+I3JwYj9CK 6vASe987TauaqW+3LaoRabq0Pb49SNP3WdvOYgRyiciN/NNnY0FHJiFlSKMJkrPw82 ksGXQqucf7I39TjpJyKX2ERN8F3G7lAnT4y4/HWrtlWpag+8EKP7vNQavJvNsvPKPi TUzCI5USFsmLQ== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Jul 2022 21:50:03 +0200 Message-Id: <20220706195003.16703-2-timo@rothenpieler.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706195003.16703-1-timo@rothenpieler.org> References: <20220706195003.16703-1-timo@rothenpieler.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avutil/hwcontext_d3d11va: fix texture_infos writes on non-fixed-size pools 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: Timo Rothenpieler 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: --- libavutil/hwcontext_d3d11va.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index e5afcb2a9d..6355bd1e29 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -166,6 +166,17 @@ static AVBufferRef *wrap_texture_buf(AVHWFramesContext *ctx, ID3D11Texture2D *te return NULL; } + if (s->nb_surfaces <= s->nb_surfaces_used) { + frames_hwctx->texture_infos = av_realloc_f(frames_hwctx->texture_infos, + s->nb_surfaces_used + 1, + sizeof(*frames_hwctx->texture_infos)); + if (!frames_hwctx->texture_infos) { + ID3D11Texture2D_Release(tex); + return NULL; + } + s->nb_surfaces = s->nb_surfaces_used + 1; + } + frames_hwctx->texture_infos[s->nb_surfaces_used].texture = tex; frames_hwctx->texture_infos[s->nb_surfaces_used].index = index; s->nb_surfaces_used++; @@ -284,7 +295,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx) } } - hwctx->texture_infos = av_calloc(ctx->initial_pool_size, sizeof(*hwctx->texture_infos)); + hwctx->texture_infos = av_realloc_f(NULL, ctx->initial_pool_size, sizeof(*hwctx->texture_infos)); if (!hwctx->texture_infos) return AVERROR(ENOMEM); s->nb_surfaces = ctx->initial_pool_size; -- 2.34.1 _______________________________________________ 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".