Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Dec 21, 2024
1 parent 8aa16d3 commit a893290
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/boost/dll/detail/windows/path_from_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace boost { namespace dll { namespace detail {
}

ec = boost::dll::detail::last_error_code();
for (unsigned i = 2; i < 1025 && static_cast<boost::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; i *= 2) {
std::wstring p(DEFAULT_PATH_SIZE_ * i, L'\0');
for (boost::winapi::DWORD_ new_size = 1024; new_size < 1024 * 1024 && static_cast<boost::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; new_size *= 2) {
std::wstring p(new_size, L'\0');
const std::size_t size = boost::winapi::GetModuleFileNameW(handle, &p[0], p.size());
if (size != 0 && size < p.size()) {
// On success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS. Resetting it manually.
Expand Down

0 comments on commit a893290

Please sign in to comment.