summaryrefslogtreecommitdiff
path: root/src/FileAllocationCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-01-11 15:35:12 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-01-11 15:35:12 +0000
commitf3b1defc97a1ce72a08631809feb869a9a3448c1 (patch)
tree1c58a880e3648d41a0e334d41218430cd46b1600 /src/FileAllocationCommand.cc
parent768f78f7713716816a21f03edcd8020ab708b4b1 (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/FileAllocationCommand.cc')
-rw-r--r--src/FileAllocationCommand.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc
index 0c4403ba..c97f676d 100644
--- a/src/FileAllocationCommand.cc
+++ b/src/FileAllocationCommand.cc
@@ -43,6 +43,8 @@
#include "util.h"
#include "DownloadEngine.h"
#include "DownloadContext.h"
+#include "a2functional.h"
+#include "RecoverableException.h"
namespace aria2 {
@@ -65,7 +67,12 @@ bool FileAllocationCommand::executeInternal()
_e->_fileAllocationMan->dropPickedEntry();
std::deque<Command*> commands;
- _fileAllocationEntry->prepareForNextAction(commands, _e);
+ try {
+ _fileAllocationEntry->prepareForNextAction(commands, _e);
+ } catch(RecoverableException& e) {
+ std::for_each(commands.begin(), commands.end(), Deleter());
+ throw;
+ }
_e->addCommand(commands);
_e->setNoWait(true);
return true;