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 5DFBC46228 for ; Tue, 13 Jun 2023 04:21:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C0C8368C3B6; Tue, 13 Jun 2023 07:21:14 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 623AA68C37B for ; Tue, 13 Jun 2023 07:21:08 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 709E710601E3 for ; Tue, 13 Jun 2023 04:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1686630068; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type: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=Gx2x+3xHhaHrq+SXFL+nGfl6nGbPXxrHSLUbQDEHjhI=; b=W0NQw0HJBYm0q3LBexu/KAt5CYHI4wLH4g1BXZyT8N/Nl4ORdRQ7AqXHaZ6ahlk1 g6n8W1fc2SkoIhlgaLP0/6s3X8uQdMdzZoteSxrNRdXhITHtsQbza8aUutwewb58zJw ZZCQPK1hKsUk2FpRlrYTazRqUiAOSSAkHNa4p+A2e7aQijn58byXOhOfsIUHpZZiqBc k2Y2GTCO8z144l5/y9N+boIiCH5CHADrsEVRvu6WbX28CAMu9dCa3qnIal/2MITJaCW X+H01OGXgQNwWS4G+BNEUTk4FnQkpcarkks3lSTLnCqrp1/xNb/daMfhORhZiOXZYGF o9OkZ1qlKg== Date: Tue, 13 Jun 2023 06:21:08 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_228541_682664444.1686630068106" Subject: [FFmpeg-devel] [PATCH 4/5] hwcontext_vulkan: free temporary array once unneeded 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: ------=_Part_228541_682664444.1686630068106 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Fixes a small memory leak. This also prevents leaks on malloc/mutex init errors. Does not depend on any other patches. Patch attached. ------=_Part_228541_682664444.1686630068106 Content-Type: text/x-diff; charset=us-ascii; name=0004-hwcontext_vulkan-free-temporary-array-once-unneeded.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0004-hwcontext_vulkan-free-temporary-array-once-unneeded.patch >From 52cdd121f986d36d18b95077f9c748bc9d7d918d Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 13 Jun 2023 04:36:54 +0200 Subject: [PATCH 4/5] hwcontext_vulkan: free temporary array once unneeded Fixes a small memory leak. This also prevents leaks on malloc/mutex init errors. --- libavutil/hwcontext_vulkan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index c86229ba65..ca802cc86e 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -1427,24 +1427,31 @@ static int vulkan_device_init(AVHWDeviceContext *ctx) vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &qf_num, qf); p->qf_mutex = av_calloc(qf_num, sizeof(*p->qf_mutex)); - if (!p->qf_mutex) + if (!p->qf_mutex) { + av_free(qf); return AVERROR(ENOMEM); + } p->nb_tot_qfs = qf_num; for (uint32_t i = 0; i < qf_num; i++) { p->qf_mutex[i] = av_calloc(qf[i].queueCount, sizeof(**p->qf_mutex)); - if (!p->qf_mutex[i]) + if (!p->qf_mutex[i]) { + av_free(qf); return AVERROR(ENOMEM); + } for (uint32_t j = 0; j < qf[i].queueCount; j++) { err = pthread_mutex_init(&p->qf_mutex[i][j], NULL); if (err != 0) { av_log(ctx, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", av_err2str(err)); + av_free(qf); return AVERROR(err); } } } + av_free(qf); + graph_index = hwctx->queue_family_index; comp_index = hwctx->queue_family_comp_index; tx_index = hwctx->queue_family_tx_index; -- 2.40.1 ------=_Part_228541_682664444.1686630068106 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". ------=_Part_228541_682664444.1686630068106--