aboutsummaryrefslogtreecommitdiff
path: root/src/torcontrol.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2017-06-14 17:32:45 +0200
committerpracticalswift <practicalswift@users.noreply.github.com>2017-06-14 17:35:37 +0200
commitf2fb132cb09efb253df44db09035d4210cc61236 (patch)
treefcfd5c9eb902f2c50b640db0e72e6e5aed5d2b71 /src/torcontrol.cpp
parent228c319a944b0ba7c835b1909ee1c2056c652eb1 (diff)
Net: Fix resource leak in ReadBinaryFile(...)
Introduced in 0b6f40d4cabb3bebf551a49a69ce36d4b0375b6a via PR #10408.
Diffstat (limited to 'src/torcontrol.cpp')
-rw-r--r--src/torcontrol.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 1883005163..eb0722cd81 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -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;