From ef712298c3f8bc2afdad783f05080443b72b3f77 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 17 Oct 2018 08:34:53 +0000 Subject: [PATCH] util: Check for file being NULL in DirectoryCommit --- src/util/system.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/system.cpp b/src/util/system.cpp index 43c6ae54ab5..2ed9cf70485 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 }