diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 97cf3faf2..f43b060aa 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -441,8 +441,9 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid,std::vectorsecond.hash) != _outgoing_file_hashes.end()) - _outgoing_file_hashes.erase(_outgoing_file_hashes.find(it->second.hash)) ; + std::map::iterator itHash = _outgoing_file_hashes.find(it->second.hash); + if(itHash != _outgoing_file_hashes.end()) + _outgoing_file_hashes.erase(itHash) ; } _local_tunnels.erase(it) ; @@ -801,6 +802,7 @@ void p3turtle::routeGenericTunnelItem(RsTurtleGenericTunnelItem *item) #ifdef P3TURTLE_DEBUG std::cerr << "p3turtle: got file map with unknown tunnel id " << (void*)item->tunnelId() << std::endl ; #endif + delete item; return ; } @@ -1107,6 +1109,7 @@ void p3turtle::sendFileData(const std::string& peerId, const std::string& hash, if(item->chunk_data == NULL) { std::cerr << "p3turtle: Warning: failed malloc of " << chunksize << " bytes for sending data packet." << std::endl ; + delete item; return ; } memcpy(item->chunk_data,(void*)((uint8_t*)data),chunksize) ;