From 7f5658d613b23034e4f6fb8a7c85245f930dfd0a Mon Sep 17 00:00:00 2001 From: David Brodsky Date: Thu, 1 Mar 2007 11:08:54 +0100 Subject: [PATCH] Fix memory leaks and crashes while stopping torrents. --- src/main/connection.cpp | 2 -- src/main/torrentclient.cpp | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/connection.cpp b/src/main/connection.cpp index 0f343f4..ebf5c75 100644 --- a/src/main/connection.cpp +++ b/src/main/connection.cpp @@ -83,8 +83,6 @@ Connection::~Connection() delete reader; delete commandReader; delete lengthReader; - delete pieceReaders; - delete pieceWriters; for (std::list::const_iterator it = commandQueue.begin(); it != commandQueue.end(); ++it) delete *it; diff --git a/src/main/torrentclient.cpp b/src/main/torrentclient.cpp index a26c3ac..7b0caaa 100644 --- a/src/main/torrentclient.cpp +++ b/src/main/torrentclient.cpp @@ -445,8 +445,13 @@ void TorrentClient::stop() trackerClient->stop(); for (std::map::const_iterator it = connections.begin(); it != connections.end(); ++it) { - it->second->close(); - delete it->second; + Connection *c = it->second; + c->close(); + storage->unmapPieces(c->getPieceWriter()); + c->destroyPieceWriters(); + storage->unmapPieces(c->getPieceReader()); + c->destroyPieceReaders(); + delete c; } connections.clear(); -- 2.11.4.GIT