[VCM] Initialize out method arguments in all erroneous cases (#15599)

This commit is contained in:
Andrey Nekrasov
2022-01-18 02:19:00 +03:00
committed by GitHub
parent 8c24d7e942
commit 167ec5a3a8
2 changed files with 18 additions and 11 deletions

View File

@@ -172,8 +172,7 @@ struct VideoCaptureReceiverPin : winrt::implements<VideoCaptureReceiverPin, IPin
return VFW_E_NOT_CONNECTED; return VFW_E_NOT_CONNECTED;
} }
_captureInputPin.copy_to(pPin); return _captureInputPin.try_copy_to(pPin) ? S_OK : E_FAIL;
return S_OK;
} }
HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE* pmt) override HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE* pmt) override
@@ -294,8 +293,7 @@ struct VideoCaptureReceiverPin : winrt::implements<VideoCaptureReceiverPin, IPin
return VFW_E_NO_ALLOCATOR; return VFW_E_NO_ALLOCATOR;
} }
_allocator.copy_to(allocator); return _allocator.try_copy_to(allocator) ? S_OK : E_FAIL;
return S_OK;
} }
HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator* allocator, BOOL readOnly) override HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator* allocator, BOOL readOnly) override

View File

@@ -117,8 +117,7 @@ HRESULT VideoCaptureProxyPin::ConnectedTo(IPin** pPin)
return VFW_E_NOT_CONNECTED; return VFW_E_NOT_CONNECTED;
} }
_connectedInputPin.try_copy_to(pPin); return _connectedInputPin.try_copy_to(pPin) ? S_OK : E_FAIL;
return S_OK;
} }
HRESULT VideoCaptureProxyPin::ConnectionMediaType(AM_MEDIA_TYPE* pmt) HRESULT VideoCaptureProxyPin::ConnectionMediaType(AM_MEDIA_TYPE* pmt)
@@ -194,6 +193,8 @@ HRESULT VideoCaptureProxyPin::EnumMediaTypes(IEnumMediaTypes** ppEnum)
return E_POINTER; return E_POINTER;
} }
*ppEnum = nullptr;
auto enumerator = winrt::make_self<MediaTypeEnumerator>(); auto enumerator = winrt::make_self<MediaTypeEnumerator>();
enumerator->_objects.emplace_back(CopyMediaType(_mediaFormat)); enumerator->_objects.emplace_back(CopyMediaType(_mediaFormat));
*ppEnum = enumerator.detach(); *ppEnum = enumerator.detach();
@@ -201,8 +202,12 @@ HRESULT VideoCaptureProxyPin::EnumMediaTypes(IEnumMediaTypes** ppEnum)
return S_OK; return S_OK;
} }
HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin**, ULONG*) HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin** pins, ULONG*)
{ {
if (pins)
{
*pins = nullptr;
}
return E_NOTIMPL; return E_NOTIMPL;
} }
@@ -246,7 +251,6 @@ HRESULT VideoCaptureProxyPin::GetFormat(AM_MEDIA_TYPE** ppmt)
LOG("VideoCaptureProxyPin::GetFormat FAILED ppmt"); LOG("VideoCaptureProxyPin::GetFormat FAILED ppmt");
return E_POINTER; return E_POINTER;
} }
*ppmt = CopyMediaType(_mediaFormat).release(); *ppmt = CopyMediaType(_mediaFormat).release();
return S_OK; return S_OK;
} }
@@ -676,8 +680,8 @@ HRESULT VideoCaptureProxyFilter::GetSyncSource(IReferenceClock** pClock)
{ {
return E_POINTER; return E_POINTER;
} }
_clock.try_copy_to(pClock); *pClock = nullptr;
return S_OK; return _clock.try_copy_to(pClock) ? S_OK : E_FAIL;
} }
GUID MapDShowSubtypeToMFT(const GUID& dshowSubtype) GUID MapDShowSubtypeToMFT(const GUID& dshowSubtype)
@@ -708,6 +712,7 @@ HRESULT VideoCaptureProxyFilter::EnumPins(IEnumPins** ppEnum)
LOG("VideoCaptureProxyFilter::EnumPins null arg provided"); LOG("VideoCaptureProxyFilter::EnumPins null arg provided");
return E_POINTER; return E_POINTER;
} }
*ppEnum = nullptr;
std::unique_lock<std::mutex> lock{ _worker_mutex }; std::unique_lock<std::mutex> lock{ _worker_mutex };
@@ -802,8 +807,12 @@ HRESULT VideoCaptureProxyFilter::EnumPins(IEnumPins** ppEnum)
return S_OK; return S_OK;
} }
HRESULT VideoCaptureProxyFilter::FindPin(LPCWSTR, IPin**) HRESULT VideoCaptureProxyFilter::FindPin(LPCWSTR, IPin** pin)
{ {
if (pin)
{
*pin = nullptr;
}
return E_NOTIMPL; return E_NOTIMPL;
} }