Skip to content

fix heap-use-after-free condition when cancelling spawned task, close… #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions include/boost/cobalt/detail/spawn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <boost/cobalt/task.hpp>
#include <boost/asio/dispatch.hpp>

#include <boost/smart_ptr/allocate_unique.hpp>

namespace boost::cobalt
{
template<typename T>
Expand Down Expand Up @@ -46,7 +44,7 @@ struct async_initiate_spawn
#else
auto alloc = asio::get_associated_allocator(h);
#endif
auto recs = std::allocate_shared<detail::task_receiver<T>>(alloc, std::move(rec));
auto recs = std::make_shared<detail::task_receiver<T>>(std::move(rec));

auto sl = asio::get_associated_cancellation_slot(h);
if (sl.is_connected())
Expand Down Expand Up @@ -108,7 +106,7 @@ struct async_initiate_spawn
#else
auto alloc = asio::get_associated_allocator(h);
#endif
auto recs = std::allocate_shared<detail::task_receiver<void>>(alloc, std::move(a.receiver_));
auto recs = std::make_shared<detail::task_receiver<void>>(std::move(a.receiver_));

if (recs->done)
return asio::dispatch(asio::get_associated_immediate_executor(h, exec),
Expand Down