diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-08-14 01:51:24 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-08-14 01:51:24 +0300 |
commit | 4f4dbe1d95b7afc2b8e6d713611d391598546c8b (patch) | |
tree | 534729dfc8f7bda66921a3101af0cb8014c17258 | |
parent | 6b72eed3bbe93b16015d38546d82b889edab87bc (diff) |
Fix corner case bug which could cause mapped_file_handle::truncate() to not allocate a new map, if coming from a zero sized file.
-rw-r--r-- | include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp | 2 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp b/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp index 94e9bf9d..da5db0c0 100644 --- a/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp @@ -102,7 +102,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type OUTCOME_TRYV(_sh.close()); return file_handle::truncate(newsize); } - if(!_sh.is_valid()) + if(!_sh.is_valid() || !_mh.is_valid()) { OUTCOME_TRY(auto &&ret, file_handle::truncate(newsize)); if(newsize > _reservation) diff --git a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp index 2409fd49..beef8cb8 100644 --- a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp @@ -112,7 +112,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type OUTCOME_TRYV(_sh.close()); return file_handle::truncate(newsize); } - if(!_sh.is_valid()) + if(!_sh.is_valid() || !_mh.is_valid()) { OUTCOME_TRY(auto &&ret, file_handle::truncate(newsize)); if(newsize > _reservation) |