From 0da3002815ed985746ba28332890a97687e40a51 Mon Sep 17 00:00:00 2001 From: mandreyel Date: Wed, 7 Nov 2018 11:08:34 +0100 Subject: [PATCH] Fix missing error code in conditional_sync --- include/mio/detail/mmap.ipp | 2 +- include/mio/mmap.hpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/mio/detail/mmap.ipp b/include/mio/detail/mmap.ipp index 1618ef1..a813fc3 100644 --- a/include/mio/detail/mmap.ipp +++ b/include/mio/detail/mmap.ipp @@ -334,7 +334,7 @@ void basic_mmap::sync(std::error_code& error) return; } - if(data() != nullptr) + if(data()) { #ifdef _WIN32 if(::FlushViewOfFile(get_mapping_start(), mapped_length_) == 0 diff --git a/include/mio/mmap.hpp b/include/mio/mmap.hpp index ed4af12..fd18d2b 100644 --- a/include/mio/mmap.hpp +++ b/include/mio/mmap.hpp @@ -372,7 +372,14 @@ private: */ template::type> - void conditional_sync() { sync(); } + void conditional_sync() + { + // This is invoked from the destructor, so not much we can do about + // failures here. + std::error_code ec; + sync(ec); + } + template typename std::enable_if::type conditional_sync() {} };