Skip to content

Commit 545bc5f

Browse files
committed
util: fix WriteBinaryFile() claiming success even if error occurred
`fclose()` is flushing any buffered data to disk, so if it fails then that could mean that the data was not completely written to disk. Thus, check if `fclose()` succeeds and only then claim success from `WriteBinaryFile()`.
1 parent 8b6e4b3 commit 545bc5f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/util/readwritefile.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ bool WriteBinaryFile(const fs::path &filename, const std::string &data)
4040
fclose(f);
4141
return false;
4242
}
43-
fclose(f);
43+
if (fclose(f) != 0) {
44+
return false;
45+
}
4446
return true;
4547
}

0 commit comments

Comments
 (0)