diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-04 15:39:47 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-04 16:01:48 +0300 |
commit | fe2c12bfe9fdc2713724bb400172e9915477cd65 (patch) | |
tree | e4445ee6344602d3676e59473cb410905a7a72ce /src/process.cpp | |
parent | get rid of SafeInt (diff) | |
download | winapi-common-fe2c12bfe9fdc2713724bb400172e9915477cd65.tar.gz winapi-common-fe2c12bfe9fdc2713724bb400172e9915477cd65.zip |
fix compiler warnings
Diffstat (limited to 'src/process.cpp')
-rw-r--r-- | src/process.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/process.cpp b/src/process.cpp index bac8bb8..2be7f0d 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -19,6 +19,7 @@ #include <cstddef> #include <cstring> +#include <limits> #include <sstream> #include <stdexcept> #include <string> @@ -305,7 +306,10 @@ std::string Process::get_exe_path() { while (true) { SetLastError(ERROR_SUCCESS); - const auto nch = ::GetModuleFileNameW(NULL, buffer.data(), buffer.size()); + if (buffer.size() > std::numeric_limits<DWORD>::max()) + throw std::range_error{"Path buffer is too large"}; + const auto nch = + ::GetModuleFileNameW(NULL, buffer.data(), static_cast<DWORD>(buffer.size())); if (nch == 0) { throw error::windows(GetLastError(), "GetModuleFileNameW"); |