Skip to content

Commit f2fb132

Browse files
Net: Fix resource leak in ReadBinaryFile(...)
Introduced in 0b6f40d via PR #10408.
1 parent 228c319 commit f2fb132

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/torcontrol.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,10 @@ static std::pair<bool,std::string> ReadBinaryFile(const fs::path &filename, size
376376
while ((n=fread(buffer, 1, sizeof(buffer), f)) > 0) {
377377
// Check for reading errors so we don't return any data if we couldn't
378378
// read the entire file (or up to maxsize)
379-
if (ferror(f))
379+
if (ferror(f)) {
380+
fclose(f);
380381
return std::make_pair(false,"");
382+
}
381383
retval.append(buffer, buffer+n);
382384
if (retval.size() > maxsize)
383385
break;

0 commit comments

Comments
 (0)