From 167ec5a3a82662b3583f95edbcf24bb17855342e Mon Sep 17 00:00:00 2001 From: Andrey Nekrasov Date: Tue, 18 Jan 2022 02:19:00 +0300 Subject: [PATCH] [VCM] Initialize out method arguments in all erroneous cases (#15599) --- .../VideoCaptureDevice.cpp | 6 ++--- .../VideoCaptureProxyFilter.cpp | 23 +++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp b/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp index ec40ea66c425..06440075173f 100644 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp +++ b/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp @@ -172,8 +172,7 @@ struct VideoCaptureReceiverPin : winrt::implements(); enumerator->_objects.emplace_back(CopyMediaType(_mediaFormat)); *ppEnum = enumerator.detach(); @@ -201,8 +202,12 @@ HRESULT VideoCaptureProxyPin::EnumMediaTypes(IEnumMediaTypes** ppEnum) return S_OK; } -HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin**, ULONG*) +HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin** pins, ULONG*) { + if (pins) + { + *pins = nullptr; + } return E_NOTIMPL; } @@ -246,7 +251,6 @@ HRESULT VideoCaptureProxyPin::GetFormat(AM_MEDIA_TYPE** ppmt) LOG("VideoCaptureProxyPin::GetFormat FAILED ppmt"); return E_POINTER; } - *ppmt = CopyMediaType(_mediaFormat).release(); return S_OK; } @@ -676,8 +680,8 @@ HRESULT VideoCaptureProxyFilter::GetSyncSource(IReferenceClock** pClock) { return E_POINTER; } - _clock.try_copy_to(pClock); - return S_OK; + *pClock = nullptr; + return _clock.try_copy_to(pClock) ? S_OK : E_FAIL; } GUID MapDShowSubtypeToMFT(const GUID& dshowSubtype) @@ -708,6 +712,7 @@ HRESULT VideoCaptureProxyFilter::EnumPins(IEnumPins** ppEnum) LOG("VideoCaptureProxyFilter::EnumPins null arg provided"); return E_POINTER; } + *ppEnum = nullptr; std::unique_lock lock{ _worker_mutex }; @@ -802,8 +807,12 @@ HRESULT VideoCaptureProxyFilter::EnumPins(IEnumPins** ppEnum) return S_OK; } -HRESULT VideoCaptureProxyFilter::FindPin(LPCWSTR, IPin**) +HRESULT VideoCaptureProxyFilter::FindPin(LPCWSTR, IPin** pin) { + if (pin) + { + *pin = nullptr; + } return E_NOTIMPL; }