diff options
Diffstat (limited to '')
| -rw-r--r-- | src/file.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/file.cpp b/src/file.cpp index 275f0fc..7d1df8e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -12,6 +12,7 @@ #include <cstddef> #include <cstdint> #include <cstring> +#include <limits> #include <stdexcept> #include <string> @@ -127,7 +128,8 @@ std::size_t File::get_size() const { if (!GetFileSizeEx(get(), &size)) throw error::windows(GetLastError(), "GetFileSizeEx"); - if (size.QuadPart < 0 || size.QuadPart > SIZE_MAX) + if (size.QuadPart < 0 || + static_cast<ULONGLONG>(size.QuadPart) > std::numeric_limits<std::size_t>::max()) throw std::runtime_error{"invalid file size"}; return static_cast<std::size_t>(size.QuadPart); } |
