Close the file on memory and read error in Downloader::repairFile

This commit is contained in:
Sude 2013-12-11 10:38:32 +02:00
parent c998207e08
commit 65f407d076

View File

@ -904,6 +904,7 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath,
if (chunk == NULL) if (chunk == NULL)
{ {
std::cout << "Memory error" << std::endl; std::cout << "Memory error" << std::endl;
fclose(outfile);
return res; return res;
} }
size = fread(chunk, 1, chunk_size, outfile); size = fread(chunk, 1, chunk_size, outfile);
@ -911,6 +912,7 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath,
{ {
std::cout << "Read error" << std::endl; std::cout << "Read error" << std::endl;
free(chunk); free(chunk);
fclose(outfile);
return res; return res;
} }
std::string hash = Util::getChunkHash(chunk, chunk_size, RHASH_MD5); std::string hash = Util::getChunkHash(chunk, chunk_size, RHASH_MD5);