From: Vsevolod Stakhov Date: Sun, 1 May 2022 11:56:01 +0000 (+0100) Subject: [Minor] Some more fixes X-Git-Tag: 3.3~288 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c5035fdbde4ee2277d1efbd111be2f88a5f16c7;p=thirdparty%2Frspamd.git [Minor] Some more fixes --- diff --git a/src/libutil/cxx/locked_file.cxx b/src/libutil/cxx/locked_file.cxx index b6d0d6215c..ca5600c5fb 100644 --- a/src/libutil/cxx/locked_file.cxx +++ b/src/libutil/cxx/locked_file.cxx @@ -148,7 +148,9 @@ auto raii_mmaped_locked_file::mmap_shared(const char *fname, int open_flags, raii_mmaped_locked_file::~raii_mmaped_locked_file() { - munmap(map, file.get_stat().st_size); + if (map != nullptr) { + munmap(map, file.get_stat().st_size); + } } raii_mmaped_locked_file::raii_mmaped_locked_file(raii_mmaped_locked_file &&other) noexcept diff --git a/src/libutil/cxx/locked_file.hxx b/src/libutil/cxx/locked_file.hxx index d136ebe72d..6ac4ffd2ca 100644 --- a/src/libutil/cxx/locked_file.hxx +++ b/src/libutil/cxx/locked_file.hxx @@ -59,7 +59,7 @@ struct raii_locked_file final { raii_locked_file() = delete; raii_locked_file(const raii_locked_file &other) = delete; private: - int fd; + int fd = -1; bool temp; std::string fname; struct stat st; @@ -94,7 +94,7 @@ private: /* Is intended to be used with map_shared */ explicit raii_mmaped_locked_file(raii_locked_file &&_file, void *_map); raii_locked_file file; - void *map{}; + void *map = nullptr; }; /**