Skip to content

Commit

Permalink
[XrdCl] Make sure operation handlers don't leak memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jan 15, 2021
1 parent 231225d commit 8b5a24f
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/XrdCl/XrdClOperationHandlers.hh
Expand Up @@ -173,10 +173,10 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<AnyObject> delrsp( response );
Response *res = GetResponse<Response>( status, response );
fun( *status, *res );
delete status;
delete response;
}

private:
Expand Down Expand Up @@ -212,9 +212,9 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<AnyObject> delrsp( response );
fun( *status );
delete status;
delete response;
}

private:
Expand Down Expand Up @@ -250,10 +250,10 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<AnyObject> delrsp( response );
Response *resp = GetResponse<Response>( status, response );
task( *status, *resp );
delete status;
delete response;
}

private:
Expand Down Expand Up @@ -291,9 +291,9 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<AnyObject> delrsp( response );
task( *status );
delete status;
delete response;
}

private:
Expand Down Expand Up @@ -328,15 +328,18 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
delete response;
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<StatInfo> delrsp;
StatInfo *info = nullptr;
if( status->IsOK() )
{
XRootDStatus st = f->Stat( false, info );
delrsp.reset( info );
}
else
info = &NullRef<StatInfo>::value;
fun( *status, *info );
if( info != &NullRef<StatInfo>::value ) delete info;
delete status;
delete response;
}

private:
Expand Down Expand Up @@ -477,6 +480,8 @@ namespace XrdCl
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<AnyObject> delrsp( response );
if( status->IsOK() )
{
Response *resp = GetResponse<Response>( response );
Expand All @@ -490,9 +495,6 @@ namespace XrdCl
}
else
this->SetException( *status );

delete status;
delete response;
}
};

Expand All @@ -511,24 +513,22 @@ namespace XrdCl
//------------------------------------------------------------------------
FutureWrapper( std::future<void> &ftr ) : FutureWrapperBase<void>( ftr )
{

}

//------------------------------------------------------------------------
//! Callback method.
//------------------------------------------------------------------------
void HandleResponse( XRootDStatus *status, AnyObject *response )
{
std::unique_ptr<XRootDStatus> delst( status );
std::unique_ptr<AnyObject> delrsp( response );
if( status->IsOK() )
{
prms.set_value();
fulfilled = true;
}
else
SetException( *status );

delete status;
delete response;
}
};

Expand Down

0 comments on commit 8b5a24f

Please sign in to comment.