From 24df3a164d8acee23c829a51a7722e9112a7c9ed Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 27 Sep 2024 13:33:52 -0700 Subject: [PATCH] Fix /analyze warning (#261) --- Src/ScreenGrab.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Src/ScreenGrab.cpp b/Src/ScreenGrab.cpp index 1787065..83b0a24 100644 --- a/Src/ScreenGrab.cpp +++ b/Src/ScreenGrab.cpp @@ -177,7 +177,14 @@ namespace nullptr, IID_GRAPHICS_PPV_ARGS(pStaging)); if (FAILED(hr)) + { + if (*pStaging) + { + (*pStaging)->Release(); + *pStaging = nullptr; + } return hr; + } SetDebugObjectName(*pStaging, L"ScreenGrab staging"); @@ -205,7 +212,11 @@ namespace hr = commandList->Close(); if (FAILED(hr)) + { + (*pStaging)->Release(); + *pStaging = nullptr; return hr; + } // Execute the command list pCommandQ->ExecuteCommandLists(1, CommandListCast(commandList.GetAddressOf())); @@ -213,7 +224,11 @@ namespace // Signal the fence hr = pCommandQ->Signal(fence.Get(), 1); if (FAILED(hr)) + { + (*pStaging)->Release(); + *pStaging = nullptr; return hr; + } // Block until the copy is complete while (fence->GetCompletedValue() < 1)