Fix downloader crash due to uninitialised variables.

This commit is contained in:
rh101 2021-04-25 18:20:25 +10:00
parent d1027ab263
commit b1da56d401
1 changed files with 6 additions and 4 deletions

View File

@ -283,10 +283,10 @@ private:
string _tempFileName; string _tempFileName;
std::string _checksumFileName; std::string _checksumFileName;
vector<unsigned char> _buf; vector<unsigned char> _buf;
FileStream* _fs; FileStream* _fs = nullptr;
// calculate md5 in downloading time support // calculate md5 in downloading time support
FileStream* _fsMd5; // store md5 state realtime FileStream* _fsMd5 = nullptr; // store md5 state realtime
md5_state_s _md5State; md5_state_s _md5State;
@ -812,8 +812,10 @@ void DownloaderCURL::_onDownloadFinished(TaskWrapper&& wrapper, int checkState)
if (coTask._fs) { if (coTask._fs) {
do { do {
auto pFileUtils = FileUtils::getInstance(); auto pFileUtils = FileUtils::getInstance();
coTask._fs->close(); delete coTask._fs;
coTask._fsMd5->close(); coTask._fs = nullptr;
delete coTask._fsMd5;
coTask._fsMd5 = nullptr;
if (checkState & kCheckSumStateSucceed) // No need download if (checkState & kCheckSumStateSucceed) // No need download
{ {