Skip to content

Commit

Permalink
[Net] Fix resource leak in ReadBinaryFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Apr 17, 2020
1 parent 88efc96 commit 879a84a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/torcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ static std::pair<bool,std::string> ReadBinaryFile(const std::string &filename, s
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 879a84a

Please sign in to comment.