Skip to content

Commit 3b0dd88

Browse files
Copilotelinor-fung
andauthored
Initialize *ppv in comhost DllGetClassObject (#128916)
`DllGetClassObject` in `src/native/corehost/comhost/comhost.cpp` had failure paths (CLSID not in map, `get_com_delegate` failure) that returned a failure HRESULT without writing to `*ppv`, violating the COM contract that out parameters must always be initialized. Null it out on function entry. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
1 parent b0f76ec commit 3b0dd88

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/native/corehost/comhost/comhost.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ COM_API HRESULT STDMETHODCALLTYPE DllGetClassObject(
198198
_In_ REFIID riid,
199199
_Outptr_ LPVOID FAR* ppv)
200200
{
201+
if (ppv == nullptr)
202+
return E_POINTER;
203+
204+
// COM out parameters must always be initialized, including on failure paths.
205+
*ppv = nullptr;
206+
201207
// Check if the CLSID map contains a mapping
202208
clsid_map map;
203209
RETURN_HRESULT_IF_EXCEPT(map = comhost::get_clsid_map());

0 commit comments

Comments
 (0)