fix looong-standing potential dangling pointer bug reported by BMW

This commit is contained in:
Charles Kerr 2007-10-02 03:33:17 +00:00
parent 6ed2d25af7
commit 77d7cf76a1
2 changed files with 6 additions and 2 deletions

View File

@ -1320,7 +1320,7 @@ tr_peerMgrPeerStats( const tr_peerMgr * manager,
tr_netNtop( &peer->in_addr, stat->addr, sizeof(stat->addr) );
stat->port = peer->port;
stat->from = atom->from;
stat->client = peer->client;
stat->client = tr_strdup( peer->client ? peer->client : "" );
stat->progress = peer->progress;
stat->isEncrypted = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
stat->uploadToRate = tr_rcRate( peer->rateToPeer );

View File

@ -904,8 +904,12 @@ tr_torrentPeers( const tr_torrent * tor, int * peerCount )
tor->info.hash, peerCount );
}
void tr_torrentPeersFree( tr_peer_stat * peers, int peerCount UNUSED )
void
tr_torrentPeersFree( tr_peer_stat * peers, int peerCount )
{
int i;
for( i=0; i<peerCount; ++i )
tr_free( (char*) peers[i].client );
tr_free( peers );
}