From ff3ab41b18bb2dd0b4dc78a4ad6cc48ac55829ff Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 28 Nov 2006 11:33:43 +0000 Subject: [PATCH] 2006-11-20 Tatsuhiro Tsujikawa * src/DefaultBtProgressInfoFile.cc (load): Fixed memory leak when the infohash doesn't match. --- ChangeLog | 5 +++++ src/DefaultBtProgressInfoFile.cc | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86e659de..0e825280 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-11-20 Tatsuhiro Tsujikawa + + * src/DefaultBtProgressInfoFile.cc + (load): Fixed memory leak when the infohash doesn't match. + 2006-11-11 Tatsuhiro Tsujikawa * src/DefaultPeerStorage.cc diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index a524a589..74c3cabb 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -104,7 +104,7 @@ void DefaultBtProgressInfoFile::load() { } if(Util::toHex(savedInfoHash, btContext->getInfoHashLength()) != btContext->getInfoHashAsString()) { - throw new DlAbortEx("Incorrect infoHash."); + throw string("infoHashMismatch"); } if(fread(savedBitfield, pieceStorage->getBitfieldLength(), 1, file) < 1) { throw string("readError"); @@ -136,8 +136,12 @@ void DefaultBtProgressInfoFile::load() { delete [] savedInfoHash; } fclose(file); - throw new DlAbortEx(EX_SEGMENT_FILE_READ, - filename.c_str(), strerror(errno)); + if(ex == "infoHashMismatch") { + throw new DlAbortEx("The infoHash in torrent file doesn't match to one in .aria2 file."); + } else { + throw new DlAbortEx(EX_SEGMENT_FILE_READ, + filename.c_str(), strerror(errno)); + } } logger->info(MSG_LOADED_SEGMENT_FILE); }