From patchwork Fri Jul 8 22:53:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 36710 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1916:b0:8b:804:ebe9 with SMTP id bv22csp323181pzb; Fri, 8 Jul 2022 15:54:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tewec5UoI5LLHpsSTwNoiiNQh+xPje8UyOPHL43QVsFsgt9lXKEL53S+MLE67sTKcCOi2Q X-Received: by 2002:a17:907:2704:b0:72a:596f:8b9f with SMTP id w4-20020a170907270400b0072a596f8b9fmr5721033ejk.761.1657320885031; Fri, 08 Jul 2022 15:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657320885; cv=none; d=google.com; s=arc-20160816; b=BQzjIgm1w51jA4zABDELKhDoLL1xgSIDBqxp21Cu+jTlMP4lyPPEbFj+b4SmPdUp8P WiD+8wFnOmZ6lM60s16hUi/eBIOLE77Ji5QuVTnqRn0668CKyaGtgpjneiGBx4WTroFj 6CdxtkDna8KfZTjIOWT3qaJFnPUUYLLgNEA2p2JqEJnO0mo/45JIJNbeXUdF6L1hO/Ke QXplZRL9O4ePPSm72hTxWEBPBfvujhCKZom/MHKB+2VXMEGJm8GXqnsG2n4NVOYBHhJc FoJmpdGjrp0ti5Pbp5iXhz+YFJX9TQNRyZjXXmXmokrIlV8aphMesHbQQjkudq7kGCLp e/ug== 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:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=HF6X7IULf9SNAoEbW4wF0+vD34GNSNpwJEzTVIq2fNc=; b=J2i+prOmQ4fmtjBEme7e4N9j9osY/Z/ui+/WCRcS+UfyCv0woDxYUm0IpO73JVucaC PyeaEI8iEnBP172LduQdsNCuQN5emJ5Jm5U6j4Sc+tR1N4JMVd8qULoaZp5bA+zwUZBZ QXrDb7SFG4ZGDo/j++xwoDuI5vi1MQbBLWT0OYwuvuO/G4qYpqCgldD3viGj2G5SVLY8 ziOtKyF8sLnDU8WxXx+qA+4KbsSMcPpTWwZPKzJQ7CayESXFN35HmywVQv2R17xrMzwr QEppOUNjcHcB495RNQf5YIuYp5gsO74ui3RXOzA5Nv0+gUXZ9gIvBdH6vlKMCic/EwR0 o3HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=PKKCKZlg; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rothenpieler.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qb12-20020a1709077e8c00b0070fc7c9d71dsi41257290ejc.989.2022.07.08.15.54.44; Fri, 08 Jul 2022 15:54:45 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=PKKCKZlg; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rothenpieler.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A87DD68B970; Sat, 9 Jul 2022 01:54:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [136.243.74.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 86F8F68B793 for ; Sat, 9 Jul 2022 01:54:22 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 4632B316FAE; Sat, 9 Jul 2022 00:54:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1657320861; bh=NjPytgcci73A/SdvACKFfVvC72pm+MpFO1LURbVJDME=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PKKCKZlgN6A66IDbmGDaDuSksnGoXDhKx2CyXHshD6a7eokaHMCdM3tFCd0UQKw1C OygMEA8quOfODgatixtXv3h4enCje/RxLA0iYmczc05oGQhwZfKpFLoxtTzztJafth GxHGAkVHU26z+RDeSEqPdWgjmFW1EGMDww12VZzx2lgLm8q29rCAYHreCSHFe8X7wI aW4QBh1nApZFOMHUa/3hOP5JFg8EGevm3je20VZzJuRk249NmGyuSD4lNKncy5Hq4r 2elfnT93IkwlYifJVNG+tX7DoN1U3j44bNLsivGDTrBJ2kpwcZXbb2QMBlule9wPgQ zJviNkjxSUxjA== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Jul 2022 00:53:59 +0200 Message-Id: <20220708225404.23748-4-timo@rothenpieler.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708225404.23748-1-timo@rothenpieler.org> References: <20220708225404.23748-1-timo@rothenpieler.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/8] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F3VNMJPNSrwp --- 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;