io_win32: test return of GetFileSize for errors

This commit is contained in:
Danny Robson 2018-08-23 13:59:14 +10:00
parent 058a86ba05
commit 676154d652

View File

@ -69,7 +69,11 @@ mapped_file::mapped_file (::cruft::win32::handle &&src,
// I would rather perform checks on filesize after mapping, but mapping
// requires a check for empty files before we perform the mapping to
// detect errors it throws in that specific situation.
DWORD hi_size, lo_size = GetFileSize (m_file, &hi_size);
DWORD hi_size;
DWORD lo_size = GetFileSize (m_file, &hi_size);
if (lo_size == INVALID_FILE_SIZE)
::cruft::win32::error::throw_code ();
m_size = static_cast<uint64_t> (hi_size) << 32 | lo_size;
m_mapping.reset (