diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-01-11 15:35:12 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-01-11 15:35:12 +0000 |
| commit | f3b1defc97a1ce72a08631809feb869a9a3448c1 (patch) | |
| tree | 1c58a880e3648d41a0e334d41218430cd46b1600 /src/CheckIntegrityCommand.cc | |
| parent | 768f78f7713716816a21f03edcd8020ab708b4b1 (diff) | |
2010-01-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed memory leak. Commands stored in std::deque<Command*> are not
deleted when exception is thrown. Make sure that when passing
std::deque<Command*> to function to store Commands, handle
exception and delete these Commands.
* src/AbstractCommand.cc
* src/CheckIntegrityCommand.cc
* src/FileAllocationCommand.cc
* src/RequestGroup.cc
* src/TrackerWatcherCommand.cc
Diffstat (limited to 'src/CheckIntegrityCommand.cc')
| -rw-r--r-- | src/CheckIntegrityCommand.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/CheckIntegrityCommand.cc b/src/CheckIntegrityCommand.cc index 29fc8b75..dc9d155f 100644 --- a/src/CheckIntegrityCommand.cc +++ b/src/CheckIntegrityCommand.cc @@ -40,6 +40,8 @@ #include "message.h" #include "prefs.h" #include "DownloadContext.h" +#include "a2functional.h" +#include "RecoverableException.h" namespace aria2 { @@ -68,13 +70,23 @@ bool CheckIntegrityCommand::executeInternal() logger->notice(MSG_VERIFICATION_SUCCESSFUL, _requestGroup->getDownloadContext()->getBasePath().c_str()); std::deque<Command*> commands; - _entry->onDownloadFinished(commands, _e); + try { + _entry->onDownloadFinished(commands, _e); + } catch(RecoverableException& e) { + std::for_each(commands.begin(), commands.end(), Deleter()); + throw; + } _e->addCommand(commands); } else { logger->error(MSG_VERIFICATION_FAILED, _requestGroup->getDownloadContext()->getBasePath().c_str()); std::deque<Command*> commands; - _entry->onDownloadIncomplete(commands,_e); + try { + _entry->onDownloadIncomplete(commands,_e); + } catch(RecoverableException& e) { + std::for_each(commands.begin(), commands.end(), Deleter()); + throw; + } _e->addCommand(commands); } _e->setNoWait(true); |
