From patchwork Wed Jul 6 19:50:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 36694 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp4413616pzh; Wed, 6 Jul 2022 12:50:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vy0BBJDAI+9jxqn4B/kL+Ej2Ejles+xtRuHz9e9XLLa1NG+Q67+OC4519UnzcT10aD0R61 X-Received: by 2002:a05:6402:50ce:b0:435:a2bf:e44d with SMTP id h14-20020a05640250ce00b00435a2bfe44dmr57181666edb.386.1657137041646; Wed, 06 Jul 2022 12:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657137041; cv=none; d=google.com; s=arc-20160816; b=R1uQQfd4kpMhObpEsMZYYEqtdIP3XwI4b0Uduaei5Mb73oPGmiKgAwCyfaTC74cYkH LTDaZkCGCPCyi+cHhWVSvZfriXnvvhzoyVuGosnGC4iiJkGR8OmpZtCNvJI6Fa9+bjaN MReojxldTLLR6n6o+OfKojs3N3m1dnqCmBbMrpFftJ6zrSfseUa0Jm1Qj6HDuz8RNIJd fnF4Ghq2z4szcN2wt8q3cJ7sPT1GaKEHPwnCVgfdx7uwxgAKPC7B5oXnhj6uPK/b3bkh krmxYQiIrLwNPROQ+xbxnplZE6OQQ5vPwPOdHKIii0NGP0d8Qm5+y3dYqCGC4RfiT4ZU M+kg== 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=tAlkQfPXOTDsElmnT4X9rcFzXGxFx7wgI9HN4O1DeWyxQ8BAziRrzsyGFG6THU+zM/ 85eXUs21j/CPNRxEiQTE4+T5+McGehMaCpWo1pNSAmQOyNteYq4rNNiG661YiNwzjnbT TgWG0KeiDJGvJAKPYAm7yHdvuSjojpJY+Qnlsic1U9lCBp0ws4CthqE2GAQnPTIMQXg8 WIje8+decn1NmkEI6ibqMjRgkbxykhMsdntiRdZnv33sNE8uNHKnmXdmR5vCZXALK1UZ HFCm0NhHuJ8z/vM2YbpzdRtTB0ym1+PZM9YEsOwuBoJ+Dqe84OEgQP7z2JQnDhsXNIxG FreA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=GS18QhHA; 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 hv17-20020a17090760d100b0072ad602a2d0si11671540ejc.160.2022.07.06.12.50.41; Wed, 06 Jul 2022 12:50:41 -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=GS18QhHA; 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 7300B68BABD; Wed, 6 Jul 2022 22:50:28 +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 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rbv+MrzoeykU --- 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;