mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Fix unclosed file handle in Util::createXML
File handle for input file was not closed in case of errors. Added fclose() to all error cases.
This commit is contained in:
parent
8683fe0a4e
commit
f559c6c014
@ -146,6 +146,7 @@ int Util::createXML(std::string filepath, uintmax_t chunk_size, std::string xml_
|
||||
if(!rhash_context)
|
||||
{
|
||||
std::cerr << "error: couldn't initialize rhash context" << std::endl;
|
||||
fclose(infile);
|
||||
return res;
|
||||
}
|
||||
char rhash_result[rhash_get_hash_length(RHASH_MD5)];
|
||||
@ -160,6 +161,7 @@ int Util::createXML(std::string filepath, uintmax_t chunk_size, std::string xml_
|
||||
if (chunk == NULL)
|
||||
{
|
||||
std::cerr << "Memory error" << std::endl;
|
||||
fclose(infile);
|
||||
return res;
|
||||
}
|
||||
size = fread(chunk, 1, chunk_size, infile);
|
||||
@ -167,6 +169,7 @@ int Util::createXML(std::string filepath, uintmax_t chunk_size, std::string xml_
|
||||
{
|
||||
std::cerr << "Read error" << std::endl;
|
||||
free(chunk);
|
||||
fclose(infile);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user