diff options
| author | practicalswift <[email protected]> | 2017-06-14 17:32:45 +0200 |
|---|---|---|
| committer | practicalswift <[email protected]> | 2017-06-14 17:35:37 +0200 |
| commit | f2fb132cb09efb253df44db09035d4210cc61236 (patch) | |
| tree | fcfd5c9eb902f2c50b640db0e72e6e5aed5d2b71 /src/torcontrol.cpp | |
| parent | Merge #9895: Turn TryCreateDirectory() into TryCreateDirectories() (diff) | |
| download | discoin-f2fb132cb09efb253df44db09035d4210cc61236.tar.xz discoin-f2fb132cb09efb253df44db09035d4210cc61236.zip | |
Net: Fix resource leak in ReadBinaryFile(...)
Introduced in 0b6f40d4cabb3bebf551a49a69ce36d4b0375b6a via PR #10408.
Diffstat (limited to 'src/torcontrol.cpp')
| -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 188300516..eb0722cd8 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; |