diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2017-06-16 16:34:34 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2017-06-16 16:36:42 -0700 |
commit | de8db47b7ff351f3287c5efb85102ba8836058d6 (patch) | |
tree | 77d954f3da739176f85585a5ef4c1fae68561130 /src | |
parent | d76e84a21416ef77e78138e326d4d249454e79dc (diff) | |
parent | f2fb132cb09efb253df44db09035d4210cc61236 (diff) |
Merge #10587: Net: Fix resource leak in ReadBinaryFile(...)
f2fb132cb Net: Fix resource leak in ReadBinaryFile(...) (practicalswift)
Tree-SHA512: 879b9334d8bb681fa4b6f96d8ecb54e2a8948065f7be5fe7880131479c813602fc9d4a4314f043e6591e1aed50ffafa7c247362a9cdeb049b0721170e227b89a
Diffstat (limited to 'src')
-rw-r--r-- | src/torcontrol.cpp | 4 |
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; |