Browse Source

Net: Fix resource leak in ReadBinaryFile(...)

Introduced in 3290567bbd via PR #2177.
pull/40/head^2
practicalswift 7 years ago
committed by Jack Grigg
parent
commit
1240717431
No known key found for this signature in database GPG Key ID: 665DBCD284F7DAFF
  1. 4
      src/torcontrol.cpp

4
src/torcontrol.cpp

@ -376,8 +376,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;

Loading…
Cancel
Save