Skip to content

Commit

Permalink
[VCM] Initialize out method arguments in all erroneous cases (microso…
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe authored Jan 17, 2022
1 parent 8c24d7e commit 167ec5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ struct VideoCaptureReceiverPin : winrt::implements<VideoCaptureReceiverPin, IPin
return VFW_E_NOT_CONNECTED;
}

_captureInputPin.copy_to(pPin);
return S_OK;
return _captureInputPin.try_copy_to(pPin) ? S_OK : E_FAIL;
}

HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE* pmt) override
Expand Down Expand Up @@ -294,8 +293,7 @@ struct VideoCaptureReceiverPin : winrt::implements<VideoCaptureReceiverPin, IPin
return VFW_E_NO_ALLOCATOR;
}

_allocator.copy_to(allocator);
return S_OK;
return _allocator.try_copy_to(allocator) ? S_OK : E_FAIL;
}

HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator* allocator, BOOL readOnly) override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ HRESULT VideoCaptureProxyPin::ConnectedTo(IPin** pPin)
return VFW_E_NOT_CONNECTED;
}

_connectedInputPin.try_copy_to(pPin);
return S_OK;
return _connectedInputPin.try_copy_to(pPin) ? S_OK : E_FAIL;
}

HRESULT VideoCaptureProxyPin::ConnectionMediaType(AM_MEDIA_TYPE* pmt)
Expand Down Expand Up @@ -194,15 +193,21 @@ HRESULT VideoCaptureProxyPin::EnumMediaTypes(IEnumMediaTypes** ppEnum)
return E_POINTER;
}

*ppEnum = nullptr;

auto enumerator = winrt::make_self<MediaTypeEnumerator>();
enumerator->_objects.emplace_back(CopyMediaType(_mediaFormat));
*ppEnum = enumerator.detach();

return S_OK;
}

HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin**, ULONG*)
HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin** pins, ULONG*)
{
if (pins)
{
*pins = nullptr;
}
return E_NOTIMPL;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -708,6 +712,7 @@ HRESULT VideoCaptureProxyFilter::EnumPins(IEnumPins** ppEnum)
LOG("VideoCaptureProxyFilter::EnumPins null arg provided");
return E_POINTER;
}
*ppEnum = nullptr;

std::unique_lock<std::mutex> lock{ _worker_mutex };

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 167ec5a

Please sign in to comment.