From bb8df11d7e036d485f52330ef9989e18541dad62 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 28 May 2015 22:15:25 +0900 Subject: [PATCH] ftp, sftp: Fix heap-after-free bug on exception --- src/FtpNegotiationCommand.cc | 2 +- src/SftpNegotiationCommand.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 09e4d1d1..afa3954e 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -467,12 +467,12 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) poolConnection(); return false; } - checkIntegrityEntry->pushNextCommand(std::unique_ptr(this)); // We have to make sure that command that has Request object must // have segment after PieceStorage is initialized. See // AbstractCommand::execute() getSegmentMan()->getSegmentWithIndex(getCuid(), 0); + checkIntegrityEntry->pushNextCommand(std::unique_ptr(this)); prepareForNextAction(std::move(checkIntegrityEntry)); disableReadCheckSocket(); diff --git a/src/SftpNegotiationCommand.cc b/src/SftpNegotiationCommand.cc index 2bfdad96..c4600abb 100644 --- a/src/SftpNegotiationCommand.cc +++ b/src/SftpNegotiationCommand.cc @@ -299,12 +299,12 @@ void SftpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) poolConnection(); return; } - checkIntegrityEntry->pushNextCommand(std::unique_ptr(this)); // We have to make sure that command that has Request object must // have segment after PieceStorage is initialized. See // AbstractCommand::execute() getSegmentMan()->getSegmentWithIndex(getCuid(), 0); + checkIntegrityEntry->pushNextCommand(std::unique_ptr(this)); prepareForNextAction(std::move(checkIntegrityEntry)); disableReadCheckSocket();