Skip to content

Commit

Permalink
Merge #10587: Net: Fix resource leak in ReadBinaryFile(...)
Browse files Browse the repository at this point in the history
f2fb132 Net: Fix resource leak in ReadBinaryFile(...) (practicalswift)

Tree-SHA512: 879b9334d8bb681fa4b6f96d8ecb54e2a8948065f7be5fe7880131479c813602fc9d4a4314f043e6591e1aed50ffafa7c247362a9cdeb049b0721170e227b89a
  • Loading branch information
sipa committed Jun 16, 2017
2 parents d76e84a + f2fb132 commit de8db47
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/torcontrol.cpp
Expand Up @@ -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) {
// Check for reading errors so we don't return any data if we couldn't
// read the entire file (or up to maxsize)
if (ferror(f))
if (ferror(f)) {
fclose(f);
return std::make_pair(false,"");
}
retval.append(buffer, buffer+n);
if (retval.size() > maxsize)
break;
Expand Down

0 comments on commit de8db47

Please sign in to comment.