mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-23 13:24:18 +00:00
Net: Fix resource leak in ReadBinaryFile(...)
Introduced in 0b6f40d4cabb3bebf551a49a69ce36d4b0375b6a via PR #10408.
This commit is contained in:
parent
228c319a94
commit
f2fb132cb0
@ -376,8 +376,10 @@ static std::pair<bool,std::string> ReadBinaryFile(const fs::path &filename, size
|
|||||||
while ((n=fread(buffer, 1, sizeof(buffer), f)) > 0) {
|
while ((n=fread(buffer, 1, sizeof(buffer), f)) > 0) {
|
||||||
// Check for reading errors so we don't return any data if we couldn't
|
// Check for reading errors so we don't return any data if we couldn't
|
||||||
// read the entire file (or up to maxsize)
|
// read the entire file (or up to maxsize)
|
||||||
if (ferror(f))
|
if (ferror(f)) {
|
||||||
|
fclose(f);
|
||||||
return std::make_pair(false,"");
|
return std::make_pair(false,"");
|
||||||
|
}
|
||||||
retval.append(buffer, buffer+n);
|
retval.append(buffer, buffer+n);
|
||||||
if (retval.size() > maxsize)
|
if (retval.size() > maxsize)
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user