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 B9567467E3 for ; Mon, 19 Jun 2023 06:19:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F345D68BFB1; Mon, 19 Jun 2023 09:19:39 +0300 (EEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B054D68BF75 for ; Mon, 19 Jun 2023 09:19:32 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687155577; x=1718691577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X7XNxg0d+HuPquyEcRoWDtuT0kQOEGtpKFbsZqS+hJw=; b=npZve1OohkgnpHnmU1jJ8JkrhK3LHxodAc2ZE+lnqjmVU5WAOuFyq4U6 mHUkXNlFylBVJN1VNQZA/CyW7sBXcBGrAY464t/ChOrEv7E0u8JdEudIU 3/gLCAPeAPZCDo49m/1fF2rppb/tvnLvUDBzlek3iLP1YGECOdvhPArY1 +yfHo4B+yNmcKwh7H6EV2rDiUe8w7hSqvNa6MY5w19egxAro83FYbmx7K F5DnnTrAVhK2GhAGL4HNqY/1Mi4FxK6kUkVeOFdzVfqJt1qV4A2GNQcjT FR3uGAv5DRl3jyxUUGAiFenUG7rMZpwjqgnE+eyUUrCXeIlZXW1Swoh70 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="362089630" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="362089630" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 23:19:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="858099919" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="858099919" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.59]) by fmsmga001.fm.intel.com with ESMTP; 18 Jun 2023 23:19:24 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Jun 2023 14:15:09 +0800 Message-ID: <20230619061509.1363-3-tong1.wu@intel.com> X-Mailer: git-send-email 2.41.0.windows.1 In-Reply-To: <20230619061509.1363-1-tong1.wu@intel.com> References: <20230619061509.1363-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/3] lavu/hwcontext_qsv: fix memory leak for d3d9 impl 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: Tong Wu 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: Signed-off-by: Tong Wu --- libavutil/hwcontext_qsv.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 1d24a04561..82c020915d 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -756,25 +756,28 @@ static int qsv_d3d9_update_config(void *ctx, mfxHDL handle, mfxConfig cfg) hr = IDirect3DDeviceManager9_LockDevice(devmgr, device_handle, &device, TRUE); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Error LockDevice %d\n", hr); + IDirect3DDeviceManager9_CloseDeviceHandle(devmgr, device_handle); goto fail; } hr = IDirect3DDevice9Ex_GetCreationParameters(device, ¶ms); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9_GetCreationParameters %d\n", hr); + IDirect3DDevice9Ex_Release(device); goto unlock; } hr = IDirect3DDevice9Ex_GetDirect3D(device, &d3d9ex); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9Ex_GetAdapterLUID %d\n", hr); + IDirect3DDevice9Ex_Release(device); goto unlock; } hr = IDirect3D9Ex_GetAdapterLUID(d3d9ex, params.AdapterOrdinal, &luid); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9Ex_GetAdapterLUID %d\n", hr); - goto unlock; + goto release; } impl_value.Type = MFX_VARIANT_TYPE_PTR; @@ -784,13 +787,18 @@ static int qsv_d3d9_update_config(void *ctx, mfxHDL handle, mfxConfig cfg) if (sts != MFX_ERR_NONE) { av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration" "DeviceLUID property: %d.\n", sts); - goto unlock; + goto release; } ret = 0; +release: + IDirect3D9Ex_Release(d3d9ex); + IDirect3DDevice9Ex_Release(device); + unlock: IDirect3DDeviceManager9_UnlockDevice(devmgr, device_handle, FALSE); + IDirect3DDeviceManager9_CloseDeviceHandle(devmgr, device_handle); fail: #endif return ret; -- 2.41.0.windows.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".