Skip to content

Commit

Permalink
fixed UB in limit_handles.
Browse files Browse the repository at this point in the history
Closes #200.
  • Loading branch information
klemens-morgenstern committed Nov 8, 2024
1 parent 58586e4 commit e8235be
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions include/boost/process/v1/detail/windows/handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ struct limit_handles_ : handler_base_ext
auto itr = std::find(all_handles.begin(), all_handles .end(), handle);
::boost::winapi::DWORD_ flags = 0u;
if (itr != all_handles.end())
*itr = ::boost::winapi::INVALID_HANDLE_VALUE_;
else if ((::boost::winapi::GetHandleInformation(*itr, &flags) != 0)
&&((flags & ::boost::winapi::HANDLE_FLAG_INHERIT_) == 0)) //it is NOT inherited anyhow, so ignore too
*itr = ::boost::winapi::INVALID_HANDLE_VALUE_;
*itr = ::boost::winapi::INVALID_HANDLE_VALUE_; // the handle is used mark it as invalid, so it doesn't get reset
});

auto part_itr = std::partition(all_handles.begin(), all_handles.end(),
Expand Down

0 comments on commit e8235be

Please sign in to comment.