From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 9852e493548..fbc42e9965e 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -1356,11 +1356,11 @@ DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags,
}
-/* This function will just create the storage for the new player. */ static lpPlayerData DP_CreatePlayer( IDirectPlayImpl *This, DPID *lpid, DPNAME *lpName, DWORD dwFlags, HANDLE hEvent, BOOL bAnsi ) { lpPlayerData lpPData; + lpPlayerList lpPList;
TRACE( "(%p)->(%p,%p,%u)\n", This, lpid, lpName, bAnsi );
@@ -1394,6 +1394,23 @@ static lpPlayerData DP_CreatePlayer( IDirectPlayImpl *This, DPID *lpid, DPNAME * /* Initialize the SP data section */ lpPData->lpSPPlayerData = DPSP_CreateSPPlayerData();
+ /* Create the list object and link it in */ + lpPList = calloc( 1, sizeof( *lpPList ) ); + if( !lpPList ) + { + free( lpPData->lpSPPlayerData ); + CloseHandle( lpPData->hEvent ); + DP_DeleteDPNameStruct( &lpPData->name ); + free( lpPData ); + return NULL; + } + + lpPData->uRef = 1; + lpPList->lpPData = lpPData; + + /* Add the player to the system group */ + DPQ_INSERT( This->dp2->lpSysGroup->players, lpPList, players ); + TRACE( "Created player id 0x%08lx\n", *lpid );
if( ~dwFlags & DPLAYI_PLAYER_SYSPLAYER ) @@ -1542,7 +1559,6 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID * { HRESULT hr = DP_OK; lpPlayerData lpPData; - lpPlayerList lpPList; DWORD dwCreateFlags = 0;
TRACE( "(%p)->(%p,%p,%p,%p,0x%08lx,0x%08lx,%u)\n", @@ -1632,20 +1648,8 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID * player total */ lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwCreateFlags, hEvent, bAnsi ); - /* Create the list object and link it in */ - lpPList = calloc( 1, sizeof( *lpPList ) ); - if( !lpPData || !lpPList ) - { - free( lpPData ); - free( lpPList ); + if( !lpPData ) return DPERR_CANTADDPLAYER; - } - - lpPData->uRef = 1; - lpPList->lpPData = lpPData; - - /* Add the player to the system group */ - DPQ_INSERT( This->dp2->lpSysGroup->players, lpPList, players );
/* Update the information and send it to all players in the session */ DP_SetPlayerData( lpPData, DPSET_REMOTE, lpData, dwDataSize );