Skip to content

Commit 70f711f

Browse files
baskanovjulliard
authored andcommitted
dplayx: Free resources on error paths in DP_SecureOpen().
1 parent bbf4dff commit 70f711f

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

dlls/dplayx/dplay.c

+44-1
Original file line numberDiff line numberDiff line change
@@ -3394,7 +3394,15 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
33943394

33953395
hr = DP_IF_CreateGroup( This, NULL, &systemGroup, NULL,
33963396
NULL, 0, 0, TRUE );
3397-
3397+
if ( FAILED( hr ) )
3398+
{
3399+
if( This->dp2->spData.lpCB->CloseEx )
3400+
{
3401+
DPSP_CLOSEDATA data;
3402+
data.lpISP = This->dp2->spData.lpISP;
3403+
(*This->dp2->spData.lpCB->CloseEx)( &data );
3404+
}
3405+
}
33983406
}
33993407

34003408
if( dwFlags & DPOPEN_JOIN )
@@ -3414,17 +3422,43 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
34143422
if( FAILED( hr ) )
34153423
{
34163424
ERR( "Request for ID failed: %s\n", DPLAYX_HresultToString( hr ) );
3425+
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
3426+
if( This->dp2->spData.lpCB->CloseEx )
3427+
{
3428+
DPSP_CLOSEDATA data;
3429+
data.lpISP = This->dp2->spData.lpISP;
3430+
(*This->dp2->spData.lpCB->CloseEx)( &data );
3431+
}
34173432
return hr;
34183433
}
34193434

34203435
hr = DP_CreatePlayer( This, NULL, &dpidServerId, NULL, NULL, 0, NULL, 0, createFlags, NULL,
34213436
bAnsi );
34223437
if( FAILED( hr ) )
3438+
{
3439+
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
3440+
if( This->dp2->spData.lpCB->CloseEx )
3441+
{
3442+
DPSP_CLOSEDATA data;
3443+
data.lpISP = This->dp2->spData.lpISP;
3444+
(*This->dp2->spData.lpCB->CloseEx)( &data );
3445+
}
34233446
return hr;
3447+
}
34243448

34253449
hr = DP_MSG_ForwardPlayerCreation( This, dpidServerId );
34263450
if( FAILED( hr ) )
3451+
{
3452+
DP_DeletePlayer( This, dpidServerId );
3453+
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
3454+
if( This->dp2->spData.lpCB->CloseEx )
3455+
{
3456+
DPSP_CLOSEDATA data;
3457+
data.lpISP = This->dp2->spData.lpISP;
3458+
(*This->dp2->spData.lpCB->CloseEx)( &data );
3459+
}
34273460
return hr;
3461+
}
34283462
}
34293463
else if( dwFlags & DPOPEN_CREATE )
34303464
{
@@ -3434,7 +3468,16 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
34343468
hr = DP_CreatePlayer( This, NULL, &dpidNameServerId, NULL, NULL, 0, NULL, 0, createFlags, NULL,
34353469
bAnsi );
34363470
if( FAILED( hr ) )
3471+
{
3472+
DP_IF_DestroyGroup( This, NULL, DPID_SYSTEM_GROUP, TRUE );
3473+
if( This->dp2->spData.lpCB->CloseEx )
3474+
{
3475+
DPSP_CLOSEDATA data;
3476+
data.lpISP = This->dp2->spData.lpISP;
3477+
(*This->dp2->spData.lpCB->CloseEx)( &data );
3478+
}
34373479
return hr;
3480+
}
34383481
}
34393482

34403483
return DP_OK;

0 commit comments

Comments
 (0)