diff --git a/src/mmap.cpp b/src/mmap.cpp index 8d969a7e69..6dc5b6ac64 100644 --- a/src/mmap.cpp +++ b/src/mmap.cpp @@ -185,7 +185,7 @@ file_mapping::file_mapping(file_handle file, open_mode_t const mode, std::int64_ } #if TORRENT_USE_MADVISE - if (file_size > 0) + if (m_mapping != nullptr && m_mapping != map_failed) { int const advise = ((mode & open_mode::sequential_access) ? MADV_SEQUENTIAL : 0) #ifdef MADV_DONTDUMP