From 545bc5f81d60fa6ff7c5cc43a2e9eef82f911466 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 18 Nov 2020 17:38:43 +0100 Subject: 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()`. --- src/util/readwritefile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/readwritefile.cpp b/src/util/readwritefile.cpp index 15e9d7a9b9..a45c41d367 100644 --- a/src/util/readwritefile.cpp +++ b/src/util/readwritefile.cpp @@ -40,6 +40,8 @@ bool WriteBinaryFile(const fs::path &filename, const std::string &data) fclose(f); return false; } - fclose(f); + if (fclose(f) != 0) { + return false; + } return true; } -- cgit v1.2.3