From 2cd1fed6ee48e7ff2f919b10cdc0ecc1982847fd Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 7 Jan 2013 22:17:28 +0100 Subject: [PATCH] dplayx: Check return of CoCreateInstance (Coverity). --- dlls/dplayx/tests/dplayx.c | 204 +++++++++++++++++++++++++------------ 1 file changed, 139 insertions(+), 65 deletions(-) diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index c6ab1853f19..a1da9e4be19 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -658,8 +658,10 @@ static void init_TCPIP_provider( LPDIRECTPLAY4 pDP, LPDIRECTPLAYLOBBY3 pDPL; HRESULT hr; - CoCreateInstance( &CLSID_DirectPlayLobby, NULL, CLSCTX_ALL, - &IID_IDirectPlayLobby3A, (LPVOID*) &pDPL ); + hr = CoCreateInstance( &CLSID_DirectPlayLobby, NULL, CLSCTX_ALL, + &IID_IDirectPlayLobby3A, (LPVOID*) &pDPL ); + ok (SUCCEEDED (hr), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n"); + if (FAILED (hr)) return; /* Service provider */ addressElements[0].guidDataType = DPAID_ServiceProvider; @@ -801,6 +803,7 @@ static BOOL CALLBACK EnumConnections_cb( LPCGUID lpguidSP, lpCallbackData callbackData = (lpCallbackData) lpContext; LPDIRECTPLAYLOBBY pDPL; + HRESULT hr; if (!callbackData->dwFlags) @@ -811,8 +814,11 @@ static BOOL CALLBACK EnumConnections_cb( LPCGUID lpguidSP, checkFlags( callbackData->dwFlags, dwFlags, FLAGS_DPCONNECTION ); /* Get info from lpConnection */ - CoCreateInstance( &CLSID_DirectPlayLobby, NULL, CLSCTX_ALL, - &IID_IDirectPlayLobby3A, (LPVOID*) &pDPL ); + hr = CoCreateInstance( &CLSID_DirectPlayLobby, NULL, CLSCTX_ALL, + &IID_IDirectPlayLobby3A, (LPVOID*) &pDPL ); + ok( SUCCEEDED(hr), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n"); + if (FAILED(hr)) + return FALSE; callbackData->dwCounter2 = 0; IDirectPlayLobby_EnumAddress( pDPL, EnumAddress_cb2, lpConnection, @@ -832,9 +838,11 @@ static void test_EnumConnections(void) HRESULT hr; - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP ); + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + ok (SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n"); + if (FAILED(hr)) return; callbackData.dwCounter1 = 0; callbackData.dwFlags = 0; @@ -929,9 +937,13 @@ static void test_InitializeConnection(void) { LPDIRECTPLAY4 pDP; + HRESULT hr; - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP ); + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + + ok (SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n"); + if (FAILED(hr)) return; IDirectPlayX_EnumConnections( pDP, &appGuid, EnumConnections_cb2, pDP, 0 ); @@ -949,8 +961,11 @@ static void test_GetCaps(void) HRESULT hr; - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP ); + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + ok (SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n"); + if (FAILED(hr)) return; + ZeroMemory( &dpcaps, sizeof(DPCAPS) ); /* Service provider not ininitialized */ @@ -1058,10 +1073,16 @@ static void test_Open(void) HRESULT hr; - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP_server ); - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP ); + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP_server ); + ok( SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" ); + if (FAILED(hr)) return; + + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + ok( SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" ); + if (FAILED(hr)) return; + ZeroMemory( &dpsd_server, sizeof(DPSESSIONDESC2) ); ZeroMemory( &dpsd, sizeof(DPSESSIONDESC2) ); @@ -1215,8 +1236,10 @@ static LPDIRECTPLAY4 create_session(DPSESSIONDESC2 *lpdpsd) DPID dpid; HRESULT hr; - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP ); + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + ok( SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" ); + if (FAILED(hr)) return NULL; init_TCPIP_provider( pDP, "127.0.0.1", 0 ); @@ -1250,8 +1273,11 @@ static void test_EnumSessions(void) UINT i; - CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, - &IID_IDirectPlay4A, (LPVOID*) &pDP ); + hr = CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + ok( SUCCEEDED(hr), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" ); + if (FAILED(hr)) return; + ZeroMemory( &dpsd, sizeof(DPSESSIONDESC2) ); callbackData.dwCounter1 = -1; /* So that after a call to EnumSessions we get the exact number of sessions */ @@ -1337,6 +1363,7 @@ static void test_EnumSessions(void) for (i=0; i