mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-06 13:10:09 +02:00
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()`.
This commit is contained in:
parent
8b6e4b3b23
commit
545bc5f81d
@ -40,6 +40,8 @@ bool WriteBinaryFile(const fs::path &filename, const std::string &data)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fclose(f);
|
if (fclose(f) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user