Skip to content

Commit 9bcf71c

Browse files
authored
Merge pull request #357 from dice-group/fix/fclose-on-nullptr
Fix: fclose call with nullptr
2 parents 33ae632 + a8c85f1 commit 9bcf71c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎include/metall/detail/file.hpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ inline bool create_file(const fs::path &file_path) {
184184
logger::perror(logger::level::error, __FILE__, __LINE__, ss.str().c_str());
185185
return false;
186186
}
187-
if (!os_fsync(fd)) return false;
187+
if (!os_fsync(fd)) {
188+
os_close(fd);
189+
return false;
190+
}
188191
if (!os_close(fd)) return false;
189192

190193
// Sync the parent directory

‎include/metall/detail/memory.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ inline std::pair<std::size_t, std::size_t> get_num_page_faults() {
130130
logger::out(logger::level::error, __FILE__, __LINE__, ss.str().c_str());
131131
minflt = majflt = 0;
132132
}
133+
134+
fclose(f);
133135
}
134-
fclose(f);
135136
#else
136137
#ifdef METALL_VERBOSE_SYSTEM_SUPPORT_WARNING
137138
#warning "get_num_page_faults() is not supported in this environment"

0 commit comments

Comments
 (0)