From 0ab31a2e9ff35c7a4d15d953ff188f4f06773448 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 21 Sep 2021 21:24:49 +0200 Subject: [PATCH] GSCapture: Fix a premature GSSource release CUnknown starts with a refcount of 0, so a "nonstandard" assignment needs to be performed, even though it looks like a COM reference leak at the first glance. --- pcsx2/GS/GSCapture.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pcsx2/GS/GSCapture.cpp b/pcsx2/GS/GSCapture.cpp index ad0dcf6bed..ed14a5a4d4 100644 --- a/pcsx2/GS/GSCapture.cpp +++ b/pcsx2/GS/GSCapture.cpp @@ -470,8 +470,10 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float } HRESULT source_hr = S_OK; - wil::com_ptr_nothrow src; - src.attach(new GSSource(m_size.x, m_size.y, fps, NULL, source_hr, dlg.m_colorspace)); + // WARNING: This increases the reference count! Right now it's fine, since GSSource inherits from CUnknown that + // starts the reference count from 0. Should this ever change and GSSource ends up with a refcount of 1 after constructing, + // change this to `.attach(new GSSource(...))`. + wil::com_ptr_nothrow src = new GSSource(m_size.x, m_size.y, fps, NULL, source_hr, dlg.m_colorspace); if (dlg.m_enc == 0) {