aboutsummaryrefslogtreecommitdiff
path: root/src/util/system.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2018-10-17 08:34:53 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2020-08-25 16:46:46 +0000
commitef712298c3f8bc2afdad783f05080443b72b3f77 (patch)
tree2b180f7dd2479894d3f8e7e8898d7f4e9129f711 /src/util/system.cpp
parent457490403853321d308c6ca6aaa90d6f8f29b4cf (diff)
downloadbitcoin-ef712298c3f8bc2afdad783f05080443b72b3f77.tar.xz
util: Check for file being NULL in DirectoryCommit
Diffstat (limited to 'src/util/system.cpp')
-rw-r--r--src/util/system.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 43c6ae54ab..2ed9cf7048 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -1047,8 +1047,10 @@ void DirectoryCommit(const fs::path &dirname)
{
#ifndef WIN32
FILE* file = fsbridge::fopen(dirname, "r");
- fsync(fileno(file));
- fclose(file);
+ if (file) {
+ fsync(fileno(file));
+ fclose(file);
+ }
#endif
}