Skip to content

Commit

Permalink
FIX: fix the incorrect parameter parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixingchen0629 committed Jul 8, 2024
1 parent 414d0d6 commit 3112564
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions include/boost/process/v2/windows/default_launcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ struct default_launcher
basic_string_view<wchar_t> args)
{
std::size_t req_size = std::accumulate(
std::begin(argv), std::end(argv), escaped_argv_length(pt.native()),
std::begin(argv), std::end(argv), pt.empty() ? 0 : escaped_argv_length(pt.native()),
[](std::size_t sz, basic_string_view<wchar_t> arg) -> std::size_t
{
return sz + 1u + escaped_argv_length(arg);
Expand All @@ -363,12 +363,24 @@ struct default_launcher
res.resize(req_size, L' ');

wchar_t * itr = &res.front();
itr += escape_argv_string(itr, res.size(), pt.native());

if (!pt.empty())
{
itr += escape_argv_string(itr, res.size(), pt.native());
}

for (const auto & a : argv)
{
itr++;
itr += escape_argv_string(itr, std::distance(itr, &res.back() + 1), a);
}

// skip the first space
if(pt.empty() && res.size() > 1)
{
return res.substr(1);
}

return res;
}

Expand Down Expand Up @@ -411,4 +423,4 @@ BOOST_PROCESS_V2_END_NAMESPACE



#endif //BOOST_PROCESS_V2_WINDOWS_DEFAULT_LAUNCHER_HPP
#endif //BOOST_PROCESS_V2_WINDOWS_DEFAULT_LAUNCHER_HPP

0 comments on commit 3112564

Please sign in to comment.