瀏覽代碼

ftp, sftp: Fix heap-after-free bug on exception

Tatsuhiro Tsujikawa 10 年之前
父節點
當前提交
bb8df11d7e
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/FtpNegotiationCommand.cc
  2. 1 1
      src/SftpNegotiationCommand.cc

+ 1 - 1
src/FtpNegotiationCommand.cc

@@ -467,12 +467,12 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
       poolConnection();
       return false;
     }
-    checkIntegrityEntry->pushNextCommand(std::unique_ptr<Command>(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<Command>(this));
     prepareForNextAction(std::move(checkIntegrityEntry));
 
     disableReadCheckSocket();

+ 1 - 1
src/SftpNegotiationCommand.cc

@@ -299,12 +299,12 @@ void SftpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
       poolConnection();
       return;
     }
-    checkIntegrityEntry->pushNextCommand(std::unique_ptr<Command>(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<Command>(this));
     prepareForNextAction(std::move(checkIntegrityEntry));
 
     disableReadCheckSocket();