Fixed memory leak in DistantChatService::locked_sendDHPublicKey.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8456 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-06-14 22:34:03 +00:00
parent dc62965760
commit 5af0716a16

View File

@ -656,15 +656,13 @@ void DistantChatService::handleRecvDHPublicKey(RsChatDHPublicKeyItem *item)
bool DistantChatService::locked_sendDHPublicKey(const DH *dh,const RsGxsId& own_gxs_id,const RsPeerId& virtual_peer_id) bool DistantChatService::locked_sendDHPublicKey(const DH *dh,const RsGxsId& own_gxs_id,const RsPeerId& virtual_peer_id)
{ {
RsChatDHPublicKeyItem *dhitem = new RsChatDHPublicKeyItem ;
if(dh == NULL) if(dh == NULL)
{ {
std::cerr << " (EE) DH struct is not initialised! Error." << std::endl; std::cerr << " (EE) DH struct is not initialised! Error." << std::endl;
delete dhitem ;
return false ; return false ;
} }
RsChatDHPublicKeyItem *dhitem = new RsChatDHPublicKeyItem ;
dhitem->public_key = BN_dup(dh->pub_key) ; dhitem->public_key = BN_dup(dh->pub_key) ;
// we should also sign the data and check the signature on the other end. // we should also sign the data and check the signature on the other end.
@ -689,6 +687,7 @@ bool DistantChatService::locked_sendDHPublicKey(const DH *dh,const RsGxsId& own_
break ; break ;
} }
free(data) ; free(data) ;
delete(dhitem);
return false; return false;
} }
free(data) ; free(data) ;